PhysicalDisk: detects virtual disks

This commit is contained in:
李通洲
2026-03-31 15:56:04 +08:00
parent d4b1ae9751
commit 0c401a0112
6 changed files with 123 additions and 104 deletions
+18
View File
@@ -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;
+6 -2
View File
@@ -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");