@@ -61,9 +61,49 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
6161
6262 return NULL ;
6363}
64+
6465#else
66+
67+ #include <devstat.h>
68+ #include <memory.h>
69+
6570const char * ffDiskIOGetIoCounters (FFlist * result , FFDiskIOOptions * options )
6671{
67- return "Fastfetch was compiled without libgeom support" ;
72+ if (checkversion () < 0 )
73+ return "checkversion() failed" ;
74+
75+ struct statinfo stats = {
76+ .dinfo = (struct devinfo * )calloc (1 , sizeof (struct devinfo )),
77+ };
78+ if (getdevs (& stats ) < 0 )
79+ return "getdevs() failed" ;
80+
81+ for (int i = 0 ; i < stats .dinfo -> numdevs ; i ++ )
82+ {
83+ struct devstat * current = & stats .dinfo -> devices [i ];
84+ if (current -> device_type & DEVSTAT_TYPE_PASS )
85+ continue ;
86+
87+ char deviceName [128 ];
88+ snprintf (deviceName , sizeof (deviceName ), "%s%d" , current -> device_name , current -> unit_number );
89+
90+ if (options -> namePrefix .length && strncmp (deviceName , options -> namePrefix .chars , options -> namePrefix .length ) != 0 )
91+ continue ;
92+
93+ FFDiskIOResult * device = (FFDiskIOResult * ) ffListAdd (result );
94+ ffStrbufInitS (& device -> name , deviceName );
95+ ffStrbufInitF (& device -> devPath , "/dev/%s" , deviceName );
96+ device -> bytesRead = current -> bytes_read ;
97+ device -> readCount = current -> num_reads ;
98+ device -> bytesWritten = current -> bytes_written ;
99+ device -> writeCount = current -> num_writes ;
100+ }
101+
102+ if (stats .dinfo -> mem_ptr )
103+ free (stats .dinfo -> mem_ptr );
104+ free (stats .dinfo );
105+
106+ return NULL ;
68107}
108+
69109#endif
0 commit comments