diff --git a/CMakeLists.txt b/CMakeLists.txt index 64a5bed20..3cb52dc5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -744,13 +744,13 @@ elseif(NetBSD) src/detection/btrfs/btrfs_nosupport.c src/detection/chassis/chassis_nbsd.c src/detection/cpu/cpu_nbsd.c - src/detection/cpucache/cpucache_nosupport.c + src/detection/cpucache/cpucache_shared.c src/detection/cpuusage/cpuusage_bsd.c src/detection/cursor/cursor_linux.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 + src/detection/physicalmemory/physicalmemory_linux.c src/detection/diskio/diskio_nbsd.c src/detection/displayserver/linux/displayserver_linux.c src/detection/displayserver/linux/drm.c diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index 290fb6b4a..378eda6b0 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -50,7 +50,7 @@ const FFSmbiosHeader* ffSmbiosNextEntry(const FFSmbiosHeader* header) return (const FFSmbiosHeader*) (p + 1); } -#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__HAIKU__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__) #include #include #include @@ -63,6 +63,9 @@ const FFSmbiosHeader* ffSmbiosNextEntry(const FFSmbiosHeader* header) #define loff_t off_t // FreeBSD doesn't have loff_t #elif defined(__sun) #define loff_t off_t +#elif defined(__NetBSD__) + #include "common/sysctl.h" + #define loff_t off_t #endif bool ffGetSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) @@ -140,7 +143,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", &buffer)) #endif { - #ifndef __sun + #if !defined(__sun) && !defined(__NetBSD__) FF_STRBUF_AUTO_DESTROY strEntryAddress = ffStrbufCreate(); #ifdef __FreeBSD__ if (!ffSettingsGetFreeBSDKenv("hint.smbios.0.mem", &strEntryAddress)) @@ -177,7 +180,13 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() if (fd < 0) return NULL; FFSmbiosEntryPoint entryPoint; - if (!ffReadFDData(fd, sizeof(entryPoint), &entryPoint)) return NULL; + #ifdef __NetBSD__ + off_t addr = (off_t) ffSysctlGetInt64("machdep.smbios", 0); + if (addr == 0) return NULL; + if (pread(fd, &entryPoint, sizeof(entryPoint), addr) < 1) return NULL; + #else + if (ffReadFDData(fd, sizeof(entryPoint), &entryPoint) < 1) return NULL; + #endif #endif uint32_t tableLength = 0; @@ -196,9 +205,11 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() tableLength = entryPoint.Smbios30.StructureTableMaximumSize; tableAddress = (loff_t) entryPoint.Smbios30.StructureTableAddress; } + else + return NULL; ffStrbufEnsureFixedLengthFree(&buffer, tableLength); - if (pread(fd, buffer.chars, tableLength, tableAddress) == tableLength) + if (pread(fd, buffer.chars, tableLength, tableAddress) == (ssize_t) tableLength) { buffer.length = tableLength; buffer.chars[buffer.length] = '\0';