Skip to content

Commit 081e8ea

Browse files
committed
Disk: support NetBSD, improve hidden partition detection
1 parent e7630ae commit 081e8ea

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ elseif(NetBSD)
687687
src/detection/cpucache/cpucache_nosupport.c
688688
src/detection/cpuusage/cpuusage_bsd.c
689689
src/detection/cursor/cursor_linux.c
690-
src/detection/disk/disk_nosupport.c
690+
src/detection/disk/disk_bsd.c
691691
src/detection/dns/dns_linux.c
692692
src/detection/physicaldisk/physicaldisk_nosupport.c
693693
src/detection/physicalmemory/physicalmemory_nosupport.c

src/detection/disk/disk_bsd.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
#include <sys/mount.h>
66
#include <sys/stat.h>
77

8+
#ifdef __NetBSD__
9+
#include <sys/types.h>
10+
#include <sys/statvfs.h>
11+
#define getfsstat(...) getvfsstat(__VA_ARGS__)
12+
#define statfs statvfs
13+
#define f_flags f_flag
14+
#endif
15+
816
#ifdef __FreeBSD__
917
#include <libgeom.h>
1018

@@ -51,7 +59,7 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk)
5159
? FF_DISK_VOLUME_TYPE_REGULAR_BIT
5260
: FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
5361
}
54-
else if(ffStrbufStartsWithS(&disk->mountpoint, "/boot") || ffStrbufStartsWithS(&disk->mountpoint, "/efi"))
62+
else if(fs->f_flags & MNT_IGNORE)
5563
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
5664
else if(!(fs->f_flags & MNT_LOCAL))
5765
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
@@ -95,7 +103,12 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
95103
#else
96104
static void detectFsInfo(struct statfs* fs, FFDisk* disk)
97105
{
98-
FF_UNUSED(fs, disk);
106+
if(fs->f_flags & MNT_IGNORE)
107+
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
108+
else if(!(fs->f_flags & MNT_LOCAL))
109+
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
110+
else
111+
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
99112
}
100113
#endif
101114

0 commit comments

Comments
 (0)