DiskIO (Linux): detect device serial number

This commit is contained in:
李通洲
2023-12-17 11:48:59 +08:00
parent d32125e988
commit 3400e40e47
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -13,6 +13,7 @@ typedef struct FFDiskIOResult
{
FFstrbuf name;
FFstrbuf interconnect;
FFstrbuf serial;
FFDiskIOPhysicalType type;
uint64_t size;
FFstrbuf devPath;
+6
View File
@@ -110,6 +110,12 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
else
device->size = 0;
}
{
ffStrbufInit(&device->serial);
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/serial", devName);
ffReadFileBuffer(pathSysBlock, &device->serial);
}
}
return NULL;