From 434a879538b013efd122aec1480462ccf55d89a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 26 Aug 2023 09:32:19 +0800 Subject: [PATCH] Disk: rename FFDiskType to FFDiskVolumeType --- src/detection/disk/disk.c | 2 +- src/detection/disk/disk.h | 2 +- src/detection/disk/disk_apple.m | 6 ++-- src/detection/disk/disk_bsd.c | 10 +++---- src/detection/disk/disk_linux.c | 14 ++++----- src/detection/disk/disk_windows.c | 6 ++-- src/modules/disk/disk.c | 48 +++++++++++++++---------------- src/modules/disk/option.h | 18 ++++++------ 8 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/detection/disk/disk.c b/src/detection/disk/disk.c index e033f6c93..00eba85c0 100644 --- a/src/detection/disk/disk.c +++ b/src/detection/disk/disk.c @@ -22,7 +22,7 @@ const char* ffDetectDisks(FFlist* disks) FF_LIST_FOR_EACH(FFDisk, disk, *disks) { if(disk->bytesTotal == 0) - disk->type |= FF_DISK_TYPE_UNKNOWN_BIT; + disk->type |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT; } return NULL; diff --git a/src/detection/disk/disk.h b/src/detection/disk/disk.h index b4d9e53e7..24c28c9cf 100644 --- a/src/detection/disk/disk.h +++ b/src/detection/disk/disk.h @@ -10,7 +10,7 @@ typedef struct FFDisk FFstrbuf mountpoint; FFstrbuf filesystem; FFstrbuf name; - FFDiskType type; + FFDiskVolumeType type; uint64_t bytesUsed; uint64_t bytesTotal; diff --git a/src/detection/disk/disk_apple.m b/src/detection/disk/disk_apple.m index 8868dd801..81bcdeb48 100644 --- a/src/detection/disk/disk_apple.m +++ b/src/detection/disk/disk_apple.m @@ -7,11 +7,11 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk) { // FreeBSD doesn't support these flags if(fs->f_flags & MNT_DONTBROWSE) - disk->type = FF_DISK_TYPE_HIDDEN_BIT; + disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT; else if(fs->f_flags & MNT_REMOVABLE) - disk->type = FF_DISK_TYPE_EXTERNAL_BIT; + disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; else - disk->type = FF_DISK_TYPE_REGULAR_BIT; + disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT; ffStrbufInitS(&disk->name, [NSFileManager.defaultManager displayNameAtPath:@(fs->f_mntonname)].UTF8String); } diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index c4414d2a1..8701f60bd 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -10,15 +10,15 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) if(ffStrbufEqualS(&disk->filesystem, "zfs")) { disk->type = !ffStrStartsWith(fs->f_mntfromname, "zroot/") || ffStrStartsWith(fs->f_mntfromname, "zroot/ROOT/") - ? FF_DISK_TYPE_REGULAR_BIT - : FF_DISK_TYPE_SUBVOLUME_BIT; + ? FF_DISK_VOLUME_TYPE_REGULAR_BIT + : FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT; } else if(!ffStrStartsWith(fs->f_mntfromname, "/dev/")) - disk->type = FF_DISK_TYPE_HIDDEN_BIT; + disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT; else if(!(fs->f_flags & MNT_LOCAL)) - disk->type = FF_DISK_TYPE_EXTERNAL_BIT; + disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; else - disk->type = FF_DISK_TYPE_REGULAR_BIT; + disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT; ffStrbufInit(&disk->name); } diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 1d2e111b4..69a85ac64 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -155,11 +155,11 @@ static void detectName(FFDisk* disk, const FFstrbuf* device) static void detectType(FF_MAYBE_UNUSED const FFlist* devices, FFDisk* currentDisk, FF_MAYBE_UNUSED const char* options) { if(ffStrbufEqualS(¤tDisk->mountpoint, "/") || ffStrbufEqualS(¤tDisk->mountpoint, "/storage/emulated")) - currentDisk->type = FF_DISK_TYPE_REGULAR_BIT; + currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT; else if(ffStrbufStartsWithS(¤tDisk->mountpoint, "/mnt/media_rw/")) - currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT; + currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; else - currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT; + currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT; } #else @@ -191,13 +191,13 @@ static bool isSubvolume(const FFlist* devices) static void detectType(const FFlist* devices, FFDisk* currentDisk, const char* options) { if(isSubvolume(devices)) - currentDisk->type = FF_DISK_TYPE_SUBVOLUME_BIT; + currentDisk->type = FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT; else if(strstr(options, "nosuid") != NULL || strstr(options, "nodev") != NULL) - currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT; + currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; else if(ffStrbufStartsWithS(¤tDisk->mountpoint, "/boot") || ffStrbufStartsWithS(¤tDisk->mountpoint, "/efi")) - currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT; + currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT; else - currentDisk->type = FF_DISK_TYPE_REGULAR_BIT; + currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT; } #endif diff --git a/src/detection/disk/disk_windows.c b/src/detection/disk/disk_windows.c index 472b9730f..ecda28889 100644 --- a/src/detection/disk/disk_windows.c +++ b/src/detection/disk/disk_windows.c @@ -34,11 +34,11 @@ const char* ffDetectDisksImpl(FFlist* disks) disk->bytesUsed = disk->bytesTotal - bytesFree; if(driveType == DRIVE_REMOVABLE || driveType == DRIVE_REMOTE || driveType == DRIVE_CDROM) - disk->type = FF_DISK_TYPE_EXTERNAL_BIT; + disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; else if(driveType == DRIVE_FIXED) - disk->type = FF_DISK_TYPE_REGULAR_BIT; + disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT; else - disk->type = FF_DISK_TYPE_HIDDEN_BIT; + disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT; ffStrbufInit(&disk->filesystem); ffStrbufInit(&disk->name); diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index a6d8b98c6..8eed33b96 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -79,11 +79,11 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) if(disk->filesystem.length) ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars); - if(disk->type & FF_DISK_TYPE_EXTERNAL_BIT) + if(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT) ffStrbufAppendS(&str, "[External]"); - else if(disk->type & FF_DISK_TYPE_SUBVOLUME_BIT) + else if(disk->type & FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT) ffStrbufAppendS(&str, "[Subvolume]"); - else if(disk->type & FF_DISK_TYPE_HIDDEN_BIT) + else if(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT) ffStrbufAppendS(&str, "[Hidden]"); } @@ -98,8 +98,8 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) double filesPercentage = disk->filesTotal > 0 ? ((double) disk->filesUsed / (double) disk->filesTotal) * 100.0 : 0; ffAppendPercentNum(&filesPercentageStr, filesPercentage, 50, 80, false); - bool isExternal = !!(disk->type & FF_DISK_TYPE_EXTERNAL_BIT); - bool isHidden = !!(disk->type & FF_DISK_TYPE_HIDDEN_BIT); + bool isExternal = !!(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT); + bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT); ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, @@ -194,7 +194,7 @@ void ffInitDiskOptions(FFDiskOptions* options) ffOptionInitModuleArg(&options->moduleArgs); ffStrbufInit(&options->folders); - options->showTypes = FF_DISK_TYPE_REGULAR_BIT | FF_DISK_TYPE_EXTERNAL_BIT; + options->showTypes = FF_DISK_VOLUME_TYPE_REGULAR_BIT | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; } bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const char* value) @@ -213,45 +213,45 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch if (ffStrEqualsIgnCase(subKey, "show-regular")) { if (ffOptionParseBoolean(value)) - options->showTypes |= FF_DISK_TYPE_REGULAR_BIT; + options->showTypes |= FF_DISK_VOLUME_TYPE_REGULAR_BIT; else - options->showTypes &= ~FF_DISK_TYPE_REGULAR_BIT; + options->showTypes &= ~FF_DISK_VOLUME_TYPE_REGULAR_BIT; return true; } if (ffStrEqualsIgnCase(subKey, "show-external")) { if (ffOptionParseBoolean(value)) - options->showTypes |= FF_DISK_TYPE_EXTERNAL_BIT; + options->showTypes |= FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; else - options->showTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT; + options->showTypes &= ~FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; return true; } if (ffStrEqualsIgnCase(subKey, "show-hidden")) { if (ffOptionParseBoolean(value)) - options->showTypes |= FF_DISK_TYPE_HIDDEN_BIT; + options->showTypes |= FF_DISK_VOLUME_TYPE_HIDDEN_BIT; else - options->showTypes &= ~FF_DISK_TYPE_HIDDEN_BIT; + options->showTypes &= ~FF_DISK_VOLUME_TYPE_HIDDEN_BIT; return true; } if (ffStrEqualsIgnCase(subKey, "show-subvolumes")) { if (ffOptionParseBoolean(value)) - options->showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT; + options->showTypes |= FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT; else - options->showTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT; + options->showTypes &= ~FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT; return true; } if (ffStrEqualsIgnCase(subKey, "show-unknown")) { if (ffOptionParseBoolean(value)) - options->showTypes |= FF_DISK_TYPE_UNKNOWN_BIT; + options->showTypes |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT; else - options->showTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT; + options->showTypes &= ~FF_DISK_VOLUME_TYPE_UNKNOWN_BIT; return true; } @@ -285,36 +285,36 @@ void ffParseDiskJsonObject(FFDiskOptions* options, yyjson_val* module) if (ffStrEqualsIgnCase(key, "showExternal")) { if (yyjson_get_bool(val)) - options->showTypes |= FF_DISK_TYPE_EXTERNAL_BIT; + options->showTypes |= FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; else - options->showTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT; + options->showTypes &= ~FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; continue; } if (ffStrEqualsIgnCase(key, "showHidden")) { if (yyjson_get_bool(val)) - options->showTypes |= FF_DISK_TYPE_HIDDEN_BIT; + options->showTypes |= FF_DISK_VOLUME_TYPE_HIDDEN_BIT; else - options->showTypes &= ~FF_DISK_TYPE_HIDDEN_BIT; + options->showTypes &= ~FF_DISK_VOLUME_TYPE_HIDDEN_BIT; continue; } if (ffStrEqualsIgnCase(key, "showSubvolumes")) { if (yyjson_get_bool(val)) - options->showTypes |= FF_DISK_TYPE_SUBVOLUME_BIT; + options->showTypes |= FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT; else - options->showTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT; + options->showTypes &= ~FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT; continue; } if (ffStrEqualsIgnCase(key, "showUnknown")) { if (yyjson_get_bool(val)) - options->showTypes |= FF_DISK_TYPE_UNKNOWN_BIT; + options->showTypes |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT; else - options->showTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT; + options->showTypes &= ~FF_DISK_VOLUME_TYPE_UNKNOWN_BIT; continue; } diff --git a/src/modules/disk/option.h b/src/modules/disk/option.h index 07e603cd1..4b0789ad0 100644 --- a/src/modules/disk/option.h +++ b/src/modules/disk/option.h @@ -4,15 +4,15 @@ #include "common/option.h" -typedef enum FFDiskType +typedef enum FFDiskVolumeType { - FF_DISK_TYPE_NONE = 0, - FF_DISK_TYPE_REGULAR_BIT = 1 << 0, - FF_DISK_TYPE_HIDDEN_BIT = 1 << 1, - FF_DISK_TYPE_EXTERNAL_BIT = 1 << 2, - FF_DISK_TYPE_SUBVOLUME_BIT = 1 << 3, - FF_DISK_TYPE_UNKNOWN_BIT = 1 << 4, -} FFDiskType; + FF_DISK_VOLUME_TYPE_NONE = 0, + FF_DISK_VOLUME_TYPE_REGULAR_BIT = 1 << 0, + FF_DISK_VOLUME_TYPE_HIDDEN_BIT = 1 << 1, + FF_DISK_VOLUME_TYPE_EXTERNAL_BIT = 1 << 2, + FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT = 1 << 3, + FF_DISK_VOLUME_TYPE_UNKNOWN_BIT = 1 << 4, +} FFDiskVolumeType; typedef struct FFDiskOptions { @@ -20,5 +20,5 @@ typedef struct FFDiskOptions FFModuleArgs moduleArgs; FFstrbuf folders; - FFDiskType showTypes; + FFDiskVolumeType showTypes; } FFDiskOptions;