Disk (NetBSD): silence compiler warnings
Some checks failed
CI / spellcheck (push) Has been cancelled
CI / No-features-test (push) Has been cancelled
CI / Linux-amd64 (push) Has been cancelled
CI / Linux-aarch64 (push) Has been cancelled
CI / Linux-armv7 (push) Has been cancelled
CI / Linux-armv6 (push) Has been cancelled
CI / Linux-riscv64 (push) Has been cancelled
CI / Linux-ppc64le (push) Has been cancelled
CI / Musl-amd64 (push) Has been cancelled
CI / macOS-universal (push) Has been cancelled
CI / SunOS-amd64 (push) Has been cancelled
CI / FreeBSD-amd64 (push) Has been cancelled
CI / DragonFly-amd64 (push) Has been cancelled
CI / OpenBSD-amd64 (push) Has been cancelled
CI / NetBSD-amd64 (push) Has been cancelled
CI / Windows-amd64 (push) Has been cancelled
CI / Release (push) Has been cancelled

Ref: ef998fe87c/sysutils/fastfetch/patches/patch-src_detection_disk_disk__bsd.c
This commit is contained in:
Carter Li 2025-01-21 09:41:40 +08:00
parent 61e9db97b9
commit 66deb4316b

View File

@ -8,7 +8,6 @@
#ifdef __NetBSD__
#include <sys/types.h>
#include <sys/statvfs.h>
#define getfsstat(...) getvfsstat(__VA_ARGS__)
#define statfs statvfs
#define f_flags f_flag
#define f_bsize f_frsize
@ -125,14 +124,22 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk)
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
{
#ifndef __NetBSD__
int size = getfsstat(NULL, 0, MNT_WAIT);
if(size <= 0)
return "getfsstat(NULL, 0, MNT_WAIT) failed";
if(size <= 0) return "getfsstat(NULL, 0, MNT_WAIT) failed";
#else
int size = getvfsstat(NULL, 0, ST_WAIT);
if(size <= 0) return "getvfsstat(NULL, 0, ST_WAIT) failed";
#endif
FF_AUTO_FREE struct statfs* buf = malloc(sizeof(*buf) * (unsigned) size);
#ifndef __NetBSD__
if(getfsstat(buf, (int) (sizeof(*buf) * (unsigned) size), MNT_NOWAIT) <= 0)
return "getfsstat(buf, size, MNT_NOWAIT) failed";
#else
if(getvfsstat(buf, sizeof(*buf) * (unsigned) size, ST_NOWAIT) <= 0)
return "getvfsstat(buf, size, ST_NOWAIT) failed";
#endif
for(struct statfs* fs = buf; fs < buf + size; ++fs)
{