diff options
Diffstat (limited to 'src/detection/memory/memory_nbsd.c')
| -rw-r--r-- | src/detection/memory/memory_nbsd.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/detection/memory/memory_nbsd.c b/src/detection/memory/memory_nbsd.c new file mode 100644 index 0000000..ca09475 --- /dev/null +++ b/src/detection/memory/memory_nbsd.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_sysctl buf; + size_t length = sizeof(buf); + if (sysctl((int[]) { CTL_VM, VM_UVMEXP2 }, 2, &buf, &length, NULL, 0) < 0) { + return "sysctl(CTL_VM, VM_UVMEXP2) 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; +} |