From 4634606a36771afc1e4cfcb0604f99f8b37ee9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Oct 2022 22:31:57 +0800 Subject: [PATCH 1/3] CpuUsage: clearify the restriction on Android --- src/detection/cpuUsage/cpuUsage_linux.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/detection/cpuUsage/cpuUsage_linux.c b/src/detection/cpuUsage/cpuUsage_linux.c index 8667fd526..1888b2b13 100644 --- a/src/detection/cpuUsage/cpuUsage_linux.c +++ b/src/detection/cpuUsage/cpuUsage_linux.c @@ -10,7 +10,13 @@ const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll) FILE* procStat = fopen("/proc/stat", "r"); if(procStat == NULL) + { + #ifdef __ANDROID__ + return "Accessing \"/proc/stat\" is restricted on Android O+"; + #else return "fopen(\"""/proc/stat\", \"r\") == NULL"; + #endif + } if (fscanf(procStat, "cpu%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64, &user, &nice, &system, &idle, &iowait, &irq, &softirq) < 0) { From de964d3e775b1563864912e8b34b67b5fbb8aabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Oct 2022 22:48:23 +0800 Subject: [PATCH 2/3] Disk: only prints useful mount points on Android fix #322 --- src/detection/disk/disk_linux.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 2ff4395a9..5a9e7713f 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -55,12 +55,21 @@ void ffDetectDisksImpl(FFDiskResult* disks) while(isspace(*currentPos)) ++currentPos; + #ifdef __ANDROID__ + if(ffStrbufEqualS(&disk->mountpoint, "/") || ffStrbufEqualS(&disk->mountpoint, "/storage/emulated")) + disk->type = FF_DISK_TYPE_REGULAR; + else if(ffStrbufStartsWithS(&disk->mountpoint, "/mnt/media_rw/")) + disk->type = FF_DISK_TYPE_EXTERNAL; + else + disk->type = FF_DISK_TYPE_HIDDEN; + #else if(strstr(currentPos, "nosuid") != NULL || strstr(currentPos, "nodev") != NULL) disk->type = FF_DISK_TYPE_EXTERNAL; else if(ffStrbufStartsWithS(&disk->mountpoint, "/boot") || ffStrbufStartsWithS(&disk->mountpoint, "/efi")) disk->type = FF_DISK_TYPE_HIDDEN; else disk->type = FF_DISK_TYPE_REGULAR; + #endif //Detects stats struct statvfs fs; From b8f14c964afd584cf6e7adeb6fa77fe4a0d30375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 28 Oct 2022 01:02:00 +0800 Subject: [PATCH 3/3] Disk: detect Windows volumes on WSL --- src/detection/disk/disk_linux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 5a9e7713f..93dee0f7d 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -20,8 +20,9 @@ void ffDetectDisksImpl(FFDiskResult* disks) //Format of the file: " ..." (Same as fstab) char* currentPos = line; - //Non pseudo filesystems have their device in /dev/, we only add those - if(strncasecmp(currentPos, "/dev/", 5) != 0) + //Non pseudo filesystems have their device in /dev/ + //DrvFs is a filesystem plugin to WSL that was designed to support interop between WSL and the Windows filesystem. + if(strncmp(currentPos, "/dev/", 5) != 0 && strncmp(currentPos, "drvfs", 5) != 0) continue; //Skip /dev/