Swap (macOS): display Unused instead of Disabled for 0/0

Fixes #2248
This commit is contained in:
Carter Li
2026-03-29 11:19:07 +08:00
parent e0eba8ce21
commit 52c7f9f973
2 changed files with 12 additions and 6 deletions
+7 -1
View File
@@ -1,7 +1,7 @@
#include "swap.h"
#include "common/sysctl.h"
#include <mach/mach.h>
#include <sys/sysctl.h>
const char* ffDetectSwap(FFlist* result) {
struct xsw_usage xsw;
@@ -10,6 +10,12 @@ const char* ffDetectSwap(FFlist* result) {
return "Failed to read vm.swapusage";
}
if (xsw.xsu_total == 0) {
if (ffSysctlGetInt("vm.compressor_mode", 4) <= 2) {
return NULL; // Swap is disabled
}
}
FFSwapResult* swap = ffListAdd(result);
ffStrbufInitStatic(&swap->name, xsw.xsu_encrypted ? "Encrypted" : "Normal");
swap->bytesTotal = xsw.xsu_total;