summaryrefslogtreecommitdiffstats
path: root/src/detection/memory/memory_obsd.c
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/memory/memory_obsd.c
Add the files
Diffstat (limited to 'src/detection/memory/memory_obsd.c')
-rw-r--r--src/detection/memory/memory_obsd.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/detection/memory/memory_obsd.c b/src/detection/memory/memory_obsd.c
new file mode 100644
index 0000000..c6da087
--- /dev/null
+++ b/src/detection/memory/memory_obsd.c
@@ -0,0 +1,18 @@
+#include "memory.h"
+#include "common/sysctl.h"
+
+#include <sys/param.h>
+#include <uvm/uvm_extern.h>
+
+const char* ffDetectMemory(FFMemoryResult* ram) {
+ struct uvmexp buf;
+ size_t length = sizeof(buf);
+ if (sysctl((int[]) { CTL_VM, VM_UVMEXP }, 2, &buf, &length, NULL, 0) < 0) {
+ return "sysctl(CTL_VM, VM_UVMEXP) failed";
+ }
+
+ ram->bytesTotal = (uint64_t) buf.npages * instance.state.platform.sysinfo.pageSize;
+ ram->bytesUsed = ((uint64_t) buf.active + (uint64_t) buf.inactive + (uint64_t) buf.wired) * instance.state.platform.sysinfo.pageSize;
+
+ return NULL;
+}