diff options
| author | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
|---|---|---|
| committer | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
| commit | 76424950e373d3b04ac3dd13019151bfba3e8423 (patch) | |
| tree | 4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/swap/swap_apple.c | |
Add the files
Diffstat (limited to 'src/detection/swap/swap_apple.c')
| -rw-r--r-- | src/detection/swap/swap_apple.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/detection/swap/swap_apple.c b/src/detection/swap/swap_apple.c new file mode 100644 index 0000000..40dda49 --- /dev/null +++ b/src/detection/swap/swap_apple.c @@ -0,0 +1,28 @@ +#include "swap.h" + +#include "common/sysctl.h" +#include <mach/mach.h> + +const char* ffDetectSwap(FFlist* result) { + struct xsw_usage xsw; + size_t size = sizeof(xsw); + if (sysctl((int[]) { CTL_VM, VM_SWAPUSAGE }, 2, &xsw, &size, NULL, 0) != 0) { + return "Failed to read vm.swapusage"; + } + + if (xsw.xsu_total == 0) { + if (__builtin_available(macOS 26.0, *)) { + // "vm.compressor_mode" no longer exists in macOS 26.0 + } else { + if (ffSysctlGetInt("vm.compressor_mode", 4) <= 2) { + return NULL; // Swap is disabled + } + } + } + + FFSwapResult* swap = FF_LIST_ADD(FFSwapResult, *result); + ffStrbufInitStatic(&swap->name, xsw.xsu_encrypted ? "Encrypted" : "Normal"); + swap->bytesTotal = xsw.xsu_total; + swap->bytesUsed = xsw.xsu_used; + return NULL; +} |