From 58e8403e1629eea03b830353f33c2686cda4ac89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 24 Dec 2023 20:53:11 +0800 Subject: [PATCH] Disk (Linux): be more careful to detect external type --- src/detection/disk/disk_linux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 8b3620af0..69adbcea0 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -210,10 +210,11 @@ static bool isRemovable(FFDisk* currentDisk) if (!ffStrStartsWith(partitionName, entry->d_name)) continue; - // /sys/block/sdx/device/delete + // /sys/block/sdx/removable ffStrbufAppendS(&basePath, entry->d_name); - ffStrbufAppendS(&basePath, "/device/delete"); - return ffPathExists(basePath.chars, FF_PATHTYPE_FILE); + ffStrbufAppendS(&basePath, "/removable"); + char removableChar = '0'; + return ffReadFileData(basePath.chars, 1, &removableChar) > 0 && removableChar == '1'; } return false;