mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-07 21:50:08 +01:00
PhysicalDisk: detects virtual disks
This commit is contained in:
@@ -2,6 +2,24 @@
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFPhysicalDiskType {
|
||||
FF_PHYSICALDISK_TYPE_NONE = 0,
|
||||
|
||||
// If none is set, it's unknown
|
||||
FF_PHYSICALDISK_TYPE_HDD = 1 << 0,
|
||||
FF_PHYSICALDISK_TYPE_SSD = 1 << 1,
|
||||
FF_PHYSICALDISK_TYPE_VIRTUAL = 1 << 2,
|
||||
|
||||
FF_PHYSICALDISK_TYPE_FIXED = 1 << 3,
|
||||
FF_PHYSICALDISK_TYPE_REMOVABLE = 1 << 4,
|
||||
|
||||
FF_PHYSICALDISK_TYPE_READWRITE = 1 << 5,
|
||||
FF_PHYSICALDISK_TYPE_READONLY = 1 << 6,
|
||||
|
||||
FF_PHYSICALDISK_TYPE_FORCE_UNSIGNED = UINT8_MAX,
|
||||
} FFPhysicalDiskType;
|
||||
static_assert(sizeof(FFPhysicalDiskType) == sizeof(uint8_t), "");
|
||||
|
||||
typedef struct FFPhysicalDiskOptions {
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ bool ffPrintPhysicalDisk(FFPhysicalDiskOptions* options) {
|
||||
ffStrbufClear(&buffer);
|
||||
ffSizeAppendNum(dev->size, &buffer);
|
||||
|
||||
const char* physicalType = dev->type & FF_PHYSICALDISK_TYPE_HDD
|
||||
const char* physicalType = dev->type & FF_PHYSICALDISK_TYPE_VIRTUAL
|
||||
? "Virtual"
|
||||
: dev->type & FF_PHYSICALDISK_TYPE_HDD
|
||||
? "HDD"
|
||||
: dev->type & FF_PHYSICALDISK_TYPE_SSD
|
||||
? "SSD"
|
||||
@@ -169,7 +171,9 @@ bool ffGeneratePhysicalDiskJsonResult(FFPhysicalDiskOptions* options, yyjson_mut
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "devPath", &dev->devPath);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "interconnect", &dev->interconnect);
|
||||
|
||||
if (dev->type & FF_PHYSICALDISK_TYPE_HDD) {
|
||||
if (dev->type & FF_PHYSICALDISK_TYPE_VIRTUAL) {
|
||||
yyjson_mut_obj_add_str(doc, obj, "kind", "Virtual");
|
||||
} else if (dev->type & FF_PHYSICALDISK_TYPE_HDD) {
|
||||
yyjson_mut_obj_add_str(doc, obj, "kind", "HDD");
|
||||
} else if (dev->type & FF_PHYSICALDISK_TYPE_SSD) {
|
||||
yyjson_mut_obj_add_str(doc, obj, "kind", "SSD");
|
||||
|
||||
Reference in New Issue
Block a user