mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
DiskIO (DragonFly): add support
This commit is contained in:
parent
3c04b0ae65
commit
5c21931a09
@ -1428,6 +1428,10 @@ elseif(FreeBSD)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "geom"
|
||||
)
|
||||
else()
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "devstat"
|
||||
)
|
||||
endif()
|
||||
elseif(OpenBSD)
|
||||
target_link_libraries(libfastfetch
|
||||
|
@ -61,9 +61,49 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <devstat.h>
|
||||
#include <memory.h>
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
{
|
||||
return "Fastfetch was compiled without libgeom support";
|
||||
if (checkversion() < 0)
|
||||
return "checkversion() failed";
|
||||
|
||||
struct statinfo stats = {
|
||||
.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo)),
|
||||
};
|
||||
if (getdevs(&stats) < 0)
|
||||
return "getdevs() failed";
|
||||
|
||||
for (int i = 0; i < stats.dinfo->numdevs; i++)
|
||||
{
|
||||
struct devstat* current = &stats.dinfo->devices[i];
|
||||
if (current->device_type & DEVSTAT_TYPE_PASS)
|
||||
continue;
|
||||
|
||||
char deviceName[128];
|
||||
snprintf(deviceName, sizeof(deviceName), "%s%d", current->device_name, current->unit_number);
|
||||
|
||||
if (options->namePrefix.length && strncmp(deviceName, options->namePrefix.chars, options->namePrefix.length) != 0)
|
||||
continue;
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
ffStrbufInitS(&device->name, deviceName);
|
||||
ffStrbufInitF(&device->devPath, "/dev/%s", deviceName);
|
||||
device->bytesRead = current->bytes_read;
|
||||
device->readCount = current->num_reads;
|
||||
device->bytesWritten = current->bytes_written;
|
||||
device->writeCount = current->num_writes;
|
||||
}
|
||||
|
||||
if (stats.dinfo->mem_ptr)
|
||||
free(stats.dinfo->mem_ptr);
|
||||
free(stats.dinfo);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user