mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
PhysicalDisk (Linux): detect readonly
This commit is contained in:
@@ -10,6 +10,8 @@ typedef enum FFPhysicalDiskType
|
||||
|
||||
FF_PHYSICALDISK_TYPE_FIXED = 1 << 2,
|
||||
FF_PHYSICALDISK_TYPE_REMOVABLE = 1 << 3,
|
||||
|
||||
FF_PHYSICALDISK_TYPE_READONLY = 1 << 2,
|
||||
} FFPhysicalDiskType;
|
||||
|
||||
typedef struct FFPhysicalDiskResult
|
||||
|
||||
@@ -109,6 +109,13 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
device->type |= removableChar == '1' ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED;
|
||||
}
|
||||
|
||||
{
|
||||
char roChar = '0';
|
||||
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/ro", devName);
|
||||
if (ffReadFileData(pathSysBlock, 1, &roChar) > 0)
|
||||
device->type |= roChar == '1' ? FF_PHYSICALDISK_TYPE_READONLY : 0;
|
||||
}
|
||||
|
||||
{
|
||||
ffStrbufInit(&device->serial);
|
||||
snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s/device/serial", devName);
|
||||
|
||||
Reference in New Issue
Block a user