From d8e4575157734fc14127e9131be107afedccf6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 17 Sep 2023 22:28:03 +0800 Subject: [PATCH] Disk (Linux): fix ZFS subvolume detection --- src/detection/disk/disk_linux.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 0460cdfd1..91a7478dc 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -144,23 +144,14 @@ static bool isSubvolume(const FFlist* disks, FFDisk* currentDisk) if(ffStrbufEqualS(¤tDisk->mountFrom, "drvfs")) // WSL Windows drives return false; - //Filter all disks which device was already found. This catches BTRFS subvolumes. - for(uint32_t i = 0; i < disks->length - 1; i++) - { - const FFDisk* otherDevice = ffListGet(disks, i); - - if(ffStrbufEqual(¤tDisk->mountFrom, &otherDevice->mountFrom)) - return true; - } - if(ffStrbufEqualS(¤tDisk->filesystem, "zfs")) { //ZFS subvolumes - uint32_t index = ffStrbufFirstIndexC(¤tDisk->filesystem, '/'); - if (index == currentDisk->filesystem.length) + uint32_t index = ffStrbufFirstIndexC(¤tDisk->mountFrom, '/'); + if (index == currentDisk->mountFrom.length) return false; - FF_STRBUF_AUTO_DESTROY zpoolName = ffStrbufCreateNS(index, currentDisk->filesystem.chars); + FF_STRBUF_AUTO_DESTROY zpoolName = ffStrbufCreateNS(index, currentDisk->mountFrom.chars); for(uint32_t i = 0; i < disks->length - 1; i++) { const FFDisk* otherDevice = ffListGet(disks, i); @@ -170,6 +161,17 @@ static bool isSubvolume(const FFlist* disks, FFDisk* currentDisk) return false; } + else + { + //Filter all disks which device was already found. This catches BTRFS subvolumes. + for(uint32_t i = 0; i < disks->length - 1; i++) + { + const FFDisk* otherDevice = ffListGet(disks, i); + + if(ffStrbufEqual(¤tDisk->mountFrom, &otherDevice->mountFrom)) + return true; + } + } return false; }