From 6e7a6174ba2bc9234d6edb8f40350d1c3f2d4bc2 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 6f4eab2bc..d9420d236 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -147,20 +147,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;