summaryrefslogtreecommitdiffstats
path: root/src/detection/swap/swap_haiku.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/swap/swap_haiku.c
Add the files
Diffstat (limited to 'src/detection/swap/swap_haiku.c')
-rw-r--r--src/detection/swap/swap_haiku.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/detection/swap/swap_haiku.c b/src/detection/swap/swap_haiku.c
new file mode 100644
index 0000000..8a3b08c
--- /dev/null
+++ b/src/detection/swap/swap_haiku.c
@@ -0,0 +1,27 @@
+#include "swap.h"
+
+#include <OS.h>
+#include <driver_settings.h>
+
+const char* ffDetectSwap(FFlist* result) {
+ system_info info;
+ if (get_system_info(&info) != B_OK) {
+ return "Error getting system info";
+ }
+
+ uint32_t pageSize = instance.state.platform.sysinfo.pageSize;
+ FFSwapResult* swap = FF_LIST_ADD(FFSwapResult, *result);
+ ffStrbufInitStatic(&swap->name, "System");
+ void* kvms = load_driver_settings("virtual_memory"); // /boot/home/config/settings/kernel/drivers/virtual_memory
+ if (kvms) {
+ const char* swapAuto = get_driver_parameter(kvms, "swap_auto", NULL, NULL);
+ if (swapAuto) {
+ ffStrbufSetStatic(&swap->name, swapAuto[0] == 'y' ? "Auto" : "Manual");
+ }
+ unload_driver_settings(kvms);
+ }
+ swap->bytesTotal = pageSize * (uint64_t) info.max_swap_pages;
+ swap->bytesUsed = pageSize * (uint64_t) (info.max_swap_pages - info.free_swap_pages);
+
+ return NULL;
+}