mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
DiskIO (NetBSD): add support
This commit is contained in:
parent
7d46b2ada5
commit
0f3ce426e9
@ -691,7 +691,7 @@ elseif(NetBSD)
|
||||
src/detection/dns/dns_linux.c
|
||||
src/detection/physicaldisk/physicaldisk_nosupport.c
|
||||
src/detection/physicalmemory/physicalmemory_nosupport.c
|
||||
src/detection/diskio/diskio_nosupport.c
|
||||
src/detection/diskio/diskio_nbsd.c
|
||||
src/detection/displayserver/linux/displayserver_linux.c
|
||||
src/detection/displayserver/linux/drm.c
|
||||
src/detection/displayserver/linux/wayland/wayland.c
|
||||
|
38
src/detection/diskio/diskio_nbsd.c
Normal file
38
src/detection/diskio/diskio_nbsd.c
Normal file
@ -0,0 +1,38 @@
|
||||
#include "diskio.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
#include <sys/iostat.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
{
|
||||
int mib[] = {CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl)};
|
||||
size_t len;
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), NULL, &len, NULL, 0) < 0)
|
||||
return "sysctl({HW_IOSTATS}, NULL) failed";
|
||||
uint32_t nDrive = (uint32_t) (len / sizeof(struct io_sysctl));
|
||||
|
||||
struct io_sysctl* stats = malloc(len);
|
||||
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), stats, &len, NULL, 0) < 0)
|
||||
return "sysctl({HW_IOSTATS}, stats) failed";
|
||||
|
||||
for (uint32_t i = 0; i < nDrive; ++i)
|
||||
{
|
||||
struct io_sysctl* st = &stats[i];
|
||||
|
||||
if (options->namePrefix.length && strncmp(st->name, options->namePrefix.chars, options->namePrefix.length) != 0)
|
||||
continue;
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
ffStrbufInitF(&device->devPath, "/dev/%s", st->name);
|
||||
ffStrbufInitS(&device->name, st->name);
|
||||
device->bytesRead = st->rbytes;
|
||||
device->readCount = st->rxfer;
|
||||
device->bytesWritten = st->wbytes;
|
||||
device->writeCount = st->wxfer;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user