From 05a8bd7f74de49e94a3c5c9dbd80d8ba23a3f27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 14 Jun 2023 22:41:40 +0800 Subject: [PATCH] Disk (Linux): don't detect WSL drives as subvolumes --- src/detection/disk/disk_linux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index f2e9d71ed..446e93b15 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -146,20 +146,23 @@ static void detectType(FF_MAYBE_UNUSED const FFlist* devices, FFDisk* currentDis static bool isSubvolume(const FFlist* devices) { - const FFstrbuf* currentDevie = ffListGet(devices, devices->length - 1); + const FFstrbuf* current = ffListGet(devices, devices->length - 1); + + if(ffStrbufEqualS(current, "drvfs")) // WSL Windows drives + return false; //Filter all disks which device was already found. This catches BTRFS subvolumes. for(uint32_t i = 0; i < devices->length - 1; i++) { const FFstrbuf* otherDevice = ffListGet(devices, i); - if(ffStrbufEqual(currentDevie, otherDevice)) + if(ffStrbufEqual(current, otherDevice)) return true; } //ZFS subvolumes: rpool///. //Test if the third slash is present. - if(strncmp(currentDevie->chars, "rpool/", 6) == 0 && ffStrHasNChars(currentDevie->chars, '/', 3)) + if(ffStrbufStartsWithS(current, "rpool/") && ffStrHasNChars(current->chars, '/', 3)) return true; return false;