mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
PhysicalDisk (Linux): detect firmware revision
This commit is contained in:
@@ -21,6 +21,7 @@ typedef struct FFPhysicalDiskResult
|
||||
FFstrbuf interconnect;
|
||||
FFstrbuf serial;
|
||||
FFstrbuf devPath;
|
||||
FFstrbuf firmwareRev;
|
||||
FFPhysicalDiskType type;
|
||||
uint64_t size;
|
||||
} FFPhysicalDiskResult;
|
||||
|
||||
@@ -56,6 +56,15 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
if (device->name.length == 0)
|
||||
ffStrbufSetS(&device->name, devName);
|
||||
|
||||
char diskseq[8] = "";
|
||||
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/diskseq", devName);
|
||||
ffReadFileData(pathSysBlock, sizeof(diskseq) - 1, diskseq);
|
||||
char* lineEnding = strchr(diskseq, '\n');
|
||||
if (lineEnding)
|
||||
*lineEnding = '\0';
|
||||
if (!ffStrEquals(diskseq, "1"))
|
||||
ffStrbufAppendF(&device->name, "-%s", diskseq);
|
||||
|
||||
if (options->namePrefix.length && !ffStrbufStartsWith(&device->name, &options->namePrefix))
|
||||
{
|
||||
ffStrbufDestroy(&device->name);
|
||||
@@ -122,6 +131,13 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
if (ffReadFileBuffer(pathSysBlock, &device->serial))
|
||||
ffStrbufTrimRightSpace(&device->serial);
|
||||
}
|
||||
|
||||
{
|
||||
ffStrbufInit(&device->firmwareRev);
|
||||
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/device/firmware_rev", devName);
|
||||
if (ffReadFileBuffer(pathSysBlock, &device->firmwareRev))
|
||||
ffStrbufTrimRightSpace(&device->firmwareRev);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user