Disk: support NetBSD, improve hidden partition detection

This commit is contained in:
Carter Li
2024-10-28 15:48:43 +08:00
parent e7630aef34
commit 081e8ea39f
2 changed files with 16 additions and 3 deletions
+1 -1
View File
@@ -687,7 +687,7 @@ elseif(NetBSD)
src/detection/cpucache/cpucache_nosupport.c
src/detection/cpuusage/cpuusage_bsd.c
src/detection/cursor/cursor_linux.c
src/detection/disk/disk_nosupport.c
src/detection/disk/disk_bsd.c
src/detection/dns/dns_linux.c
src/detection/physicaldisk/physicaldisk_nosupport.c
src/detection/physicalmemory/physicalmemory_nosupport.c
+15 -2
View File
@@ -5,6 +5,14 @@
#include <sys/mount.h>
#include <sys/stat.h>
#ifdef __NetBSD__
#include <sys/types.h>
#include <sys/statvfs.h>
#define getfsstat(...) getvfsstat(__VA_ARGS__)
#define statfs statvfs
#define f_flags f_flag
#endif
#ifdef __FreeBSD__
#include <libgeom.h>
@@ -51,7 +59,7 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk)
? FF_DISK_VOLUME_TYPE_REGULAR_BIT
: FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
}
else if(ffStrbufStartsWithS(&disk->mountpoint, "/boot") || ffStrbufStartsWithS(&disk->mountpoint, "/efi"))
else if(fs->f_flags & MNT_IGNORE)
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
else if(!(fs->f_flags & MNT_LOCAL))
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
@@ -95,7 +103,12 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
#else
static void detectFsInfo(struct statfs* fs, FFDisk* disk)
{
FF_UNUSED(fs, disk);
if(fs->f_flags & MNT_IGNORE)
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
else if(!(fs->f_flags & MNT_LOCAL))
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
else
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
}
#endif