PhysicalDisk: renames hideUnknown for hideUnused

This commit is contained in:
李通洲
2026-04-09 10:10:51 +08:00
parent 9090dbd276
commit e8e43c10fc
11 changed files with 25 additions and 25 deletions
+2 -2
View File
@@ -3643,8 +3643,8 @@
"type": "boolean",
"default": false
},
"hideUnknown": {
"description": "Hide disks with `size == 0`",
"hideUnused": {
"description": "Hide disks with `size == 0` (likely unused/unconnected)",
"type": "boolean",
"default": true
},
@@ -122,11 +122,11 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
}
if (size == 0) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNKNOWN) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNUSED) {
continue;
}
type |= FF_PHYSICALDISK_TYPE_UNKNOWN;
type |= FF_PHYSICALDISK_TYPE_UNUSED;
}
FFPhysicalDiskResult* device = (FFPhysicalDiskResult*) ffListAdd(result);
@@ -49,11 +49,11 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
}
uint64_t size = (uint64_t) provider->lg_mediasize;
if (size == 0) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNKNOWN) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNUSED) {
continue;
}
type |= FF_PHYSICALDISK_TYPE_UNKNOWN;
type |= FF_PHYSICALDISK_TYPE_UNUSED;
}
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(provider->lg_name);
@@ -55,11 +55,11 @@ static const char* searchRawDeviceFile(FFstrbuf* path, const char* diskType, FFl
FFPhysicalDiskType type = FF_PHYSICALDISK_TYPE_NONE;
uint64_t size = (uint64_t) geometry.cylinder_count * geometry.head_count * geometry.sectors_per_track * geometry.bytes_per_sector;
if (size == 0) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNKNOWN) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNUSED) {
continue;
}
type |= FF_PHYSICALDISK_TYPE_UNKNOWN;
type |= FF_PHYSICALDISK_TYPE_UNUSED;
}
FFPhysicalDiskResult* device = (FFPhysicalDiskResult*) ffListAdd(result);
@@ -40,11 +40,11 @@ static void parsePhysicalDisk(int dfd, const char* devName, FFPhysicalDiskOption
FFPhysicalDiskType type = FF_PHYSICALDISK_TYPE_NONE;
if (size == 0) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNKNOWN) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNUSED) {
return;
}
type |= FF_PHYSICALDISK_TYPE_UNKNOWN;
type |= FF_PHYSICALDISK_TYPE_UNUSED;
}
int devfd = openat(dfd, "device", O_RDONLY | O_CLOEXEC | O_PATH | O_DIRECTORY);
@@ -90,11 +90,11 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
uint64_t size = sectorsPerUnit * sectorSize;
if (size == 0) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNKNOWN) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNUSED) {
continue;
}
type |= FF_PHYSICALDISK_TYPE_UNKNOWN;
type |= FF_PHYSICALDISK_TYPE_UNUSED;
}
FFPhysicalDiskResult* device = (FFPhysicalDiskResult*) ffListAdd(result);
@@ -60,11 +60,11 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
uint64_t size = DL_GETDSIZE(&dl) * dl.d_secsize;
if (size == 0) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNKNOWN) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNUSED) {
continue;
}
type |= FF_PHYSICALDISK_TYPE_UNKNOWN;
type |= FF_PHYSICALDISK_TYPE_UNUSED;
}
FFPhysicalDiskResult* device = (FFPhysicalDiskResult*) ffListAdd(result);
@@ -33,11 +33,11 @@ static int walkDevTree(di_node_t node, di_minor_t minor, struct FFWalkTreeBundle
int64_t* nblocks;
if (di_prop_lookup_int64(DDI_DEV_T_ANY, node, "device-nblocks", &nblocks) > 0) {
if (*nblocks == 0) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNKNOWN) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNUSED) {
return DI_WALK_CONTINUE;
}
type |= FF_PHYSICALDISK_TYPE_UNKNOWN;
type |= FF_PHYSICALDISK_TYPE_UNUSED;
} else if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "device-blksize", &value) > 0) {
size = (uint64_t) ((uint64_t) *nblocks * (uint64_t) *value);
}
@@ -84,11 +84,11 @@ static const char* detectPhysicalDisk(const char* physicalType, const wchar_t* s
}
}
if (size == 0) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNKNOWN) {
if (options->hideType & FF_PHYSICALDISK_TYPE_UNUSED) {
return "Skipping unknown disk with size 0";
}
type |= FF_PHYSICALDISK_TYPE_UNKNOWN;
type |= FF_PHYSICALDISK_TYPE_UNUSED;
}
const STORAGE_DEVICE_DESCRIPTOR* sdd = NULL;
+1 -1
View File
@@ -16,7 +16,7 @@ typedef enum __attribute__((__packed__)) FFPhysicalDiskType {
FF_PHYSICALDISK_TYPE_READWRITE = 1 << 5,
FF_PHYSICALDISK_TYPE_READONLY = 1 << 6,
FF_PHYSICALDISK_TYPE_UNKNOWN = 1 << 7,
FF_PHYSICALDISK_TYPE_UNUSED = 1 << 7,
FF_PHYSICALDISK_TYPE_FORCE_UNSIGNED = UINT8_MAX,
} FFPhysicalDiskType;
+6 -6
View File
@@ -151,14 +151,14 @@ void ffParsePhysicalDiskJsonObject(FFPhysicalDiskOptions* options, yyjson_val* m
continue;
}
if (unsafe_yyjson_equals_str(key, "hideUnknown")) {
if (unsafe_yyjson_equals_str(key, "hideUnused")) {
if (!yyjson_is_bool(val)) {
ffPrintError(FF_PHYSICALDISK_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "hideUnknown must be a boolean");
ffPrintError(FF_PHYSICALDISK_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "hideUnused must be a boolean");
} else {
if (unsafe_yyjson_is_true(val)) {
options->hideType |= FF_PHYSICALDISK_TYPE_UNKNOWN;
options->hideType |= FF_PHYSICALDISK_TYPE_UNUSED;
} else {
options->hideType &= ~FF_PHYSICALDISK_TYPE_UNKNOWN;
options->hideType &= ~FF_PHYSICALDISK_TYPE_UNUSED;
}
}
continue;
@@ -225,7 +225,7 @@ bool ffGeneratePhysicalDiskJsonResult(FFPhysicalDiskOptions* options, yyjson_mut
yyjson_mut_obj_add_null(doc, obj, "readOnly");
}
yyjson_mut_obj_add_bool(doc, obj, "unknown", !!(dev->type & FF_PHYSICALDISK_TYPE_UNKNOWN));
yyjson_mut_obj_add_bool(doc, obj, "unknown", !!(dev->type & FF_PHYSICALDISK_TYPE_UNUSED));
yyjson_mut_obj_add_strbuf(doc, obj, "revision", &dev->revision);
@@ -253,7 +253,7 @@ void ffInitPhysicalDiskOptions(FFPhysicalDiskOptions* options) {
ffStrbufInit(&options->namePrefix);
options->temp = false;
options->tempConfig = (FFColorRangeConfig) { 50, 70 };
options->hideType = FF_PHYSICALDISK_TYPE_UNKNOWN;
options->hideType = FF_PHYSICALDISK_TYPE_UNUSED;
}
void ffDestroyPhysicalDiskOptions(FFPhysicalDiskOptions* options) {