diff --git a/src/detection/disk/disk.c b/src/detection/disk/disk.c index 21520b532..39c0920e5 100644 --- a/src/detection/disk/disk.c +++ b/src/detection/disk/disk.c @@ -1,6 +1,6 @@ #include "disk.h" -bool ffDiskMatchMountpoint(FFDiskOptions* options, const char* mountpoint) +bool ffDiskMatchMountpoint(FFstrbuf* folders, const char* mountpoint) { #ifdef _WIN32 const char separator = ';'; @@ -11,12 +11,12 @@ bool ffDiskMatchMountpoint(FFDiskOptions* options, const char* mountpoint) uint32_t mountpointLength = (uint32_t) strlen(mountpoint); uint32_t startIndex = 0; - while(startIndex < options->folders.length) + while(startIndex < folders->length) { - uint32_t colonIndex = ffStrbufNextIndexC(&options->folders, startIndex, separator); + uint32_t colonIndex = ffStrbufNextIndexC(folders, startIndex, separator); uint32_t folderLength = colonIndex - startIndex; - if (folderLength == mountpointLength && memcmp(options->folders.chars + startIndex, mountpoint, mountpointLength) == 0) + if (folderLength == mountpointLength && memcmp(folders->chars + startIndex, mountpoint, mountpointLength) == 0) return true; startIndex = colonIndex + 1; @@ -54,5 +54,14 @@ const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks) } } + if (options->hiddenFolders.length) + { + FF_LIST_FOR_EACH(FFDisk, disk, *disks) + { + if (ffDiskMatchMountpoint(&options->hiddenFolders, disk->mountpoint.chars)) + disk->type |= FF_DISK_VOLUME_TYPE_HIDDEN_BIT; + } + } + return NULL; } diff --git a/src/detection/disk/disk.h b/src/detection/disk/disk.h index 1700c6078..4a24f9de0 100644 --- a/src/detection/disk/disk.h +++ b/src/detection/disk/disk.h @@ -28,4 +28,4 @@ typedef struct FFDisk const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks /* list of FFDisk */); const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks); -bool ffDiskMatchMountpoint(FFDiskOptions* options, const char* mountpoint); +bool ffDiskMatchMountpoint(FFstrbuf* folders, const char* mountpoint); diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index ca6fe1bcc..f2964234a 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -145,7 +145,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { if(__builtin_expect(options->folders.length > 0, 0)) { - if(!ffDiskMatchMountpoint(options, fs->f_mntonname)) + if(!ffDiskMatchMountpoint(&options->folders, fs->f_mntonname)) continue; } else if(!ffStrEquals(fs->f_mntonname, "/") && !ffStrStartsWith(fs->f_mntfromname, "/dev/") && !ffStrEquals(fs->f_fstypename, "zfs")) diff --git a/src/detection/disk/disk_haiku.cpp b/src/detection/disk/disk_haiku.cpp index a8e934675..6bf216922 100644 --- a/src/detection/disk/disk_haiku.cpp +++ b/src/detection/disk/disk_haiku.cpp @@ -23,7 +23,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) if (__builtin_expect(options->folders.length, 0)) { - if (!ffDiskMatchMountpoint(options, path.Path())) + if (!ffDiskMatchMountpoint(&options->folders, path.Path())) continue; } diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index e7ee2e9c9..6fb7ed6c5 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -281,7 +281,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { if (__builtin_expect(options->folders.length, 0)) { - if (!ffDiskMatchMountpoint(options, device->mnt_dir)) + if (!ffDiskMatchMountpoint(&options->folders, device->mnt_dir)) continue; } else if(!isPhysicalDevice(device)) diff --git a/src/detection/disk/disk_sunos.c b/src/detection/disk/disk_sunos.c index 82cba50ce..d52a5e907 100644 --- a/src/detection/disk/disk_sunos.c +++ b/src/detection/disk/disk_sunos.c @@ -113,7 +113,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { if (__builtin_expect(options->folders.length, 0)) { - if (!ffDiskMatchMountpoint(options, device.mnt_mountp)) + if (!ffDiskMatchMountpoint(&options->folders, device.mnt_mountp)) continue; } else if(!isPhysicalDevice(&device)) diff --git a/src/detection/disk/disk_windows.c b/src/detection/disk/disk_windows.c index 48c595ca0..e8955908b 100644 --- a/src/detection/disk/disk_windows.c +++ b/src/detection/disk/disk_windows.c @@ -47,7 +47,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) if (__builtin_expect((long) options->folders.length, 0)) { - if (!ffDiskMatchMountpoint(options, buffer.chars)) + if (!ffDiskMatchMountpoint(&options->folders, buffer.chars)) continue; } else if(driveType == DRIVE_NO_ROOT_DIR) diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 68d0a89ae..4925a9576 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -205,6 +205,12 @@ bool ffParseDiskCommandOptions(FFDiskOptions* options, const char* key, const ch return true; } + if (ffStrEqualsIgnCase(subKey, "hidden-folders")) + { + ffOptionParseString(key, value, &options->hiddenFolders); + return true; + } + if (ffStrEqualsIgnCase(subKey, "show-regular")) { if (ffOptionParseBoolean(value)) @@ -293,6 +299,12 @@ void ffParseDiskJsonObject(FFDiskOptions* options, yyjson_val* module) continue; } + if (ffStrEqualsIgnCase(key, "hiddenFolders")) + { + ffStrbufSetS(&options->hiddenFolders, yyjson_get_str(val)); + continue; + } + if (ffStrEqualsIgnCase(key, "showExternal")) { if (yyjson_get_bool(val)) @@ -496,6 +508,11 @@ void ffInitDiskOptions(FFDiskOptions* options) ffOptionInitModuleArg(&options->moduleArgs, ""); ffStrbufInit(&options->folders); + #if _WIN32 || __APPLE__ || __ANDROID__ + ffStrbufInit(&options->hiddenFolders); + #else + ffStrbufInitStatic(&options->hiddenFolders, "/efi:/boot:/boot/efi"); + #endif options->showTypes = FF_DISK_VOLUME_TYPE_REGULAR_BIT | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT | FF_DISK_VOLUME_TYPE_READONLY_BIT; options->calcType = FF_DISK_CALC_TYPE_FREE; options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; diff --git a/src/modules/disk/option.h b/src/modules/disk/option.h index eb2323f4c..54573f2c3 100644 --- a/src/modules/disk/option.h +++ b/src/modules/disk/option.h @@ -29,6 +29,7 @@ typedef struct FFDiskOptions FFModuleArgs moduleArgs; FFstrbuf folders; + FFstrbuf hiddenFolders; FFDiskVolumeType showTypes; FFDiskCalcType calcType; FFPercentageModuleConfig percent;