summaryrefslogtreecommitdiffstats
path: root/src/common/impl/kmod_linux.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/common/impl/kmod_linux.c
Add the files
Diffstat (limited to 'src/common/impl/kmod_linux.c')
-rw-r--r--src/common/impl/kmod_linux.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/common/impl/kmod_linux.c b/src/common/impl/kmod_linux.c
new file mode 100644
index 0000000..204ab35
--- /dev/null
+++ b/src/common/impl/kmod_linux.c
@@ -0,0 +1,25 @@
+#include "common/kmod.h"
+#include "common/io.h"
+
+bool ffKmodLoaded(const char* modName) {
+ static FFstrbuf modules;
+ if (modules.chars == NULL) {
+ ffStrbufInitS(&modules, "\n");
+ ffAppendFileBuffer("/proc/modules", &modules);
+ }
+
+ if (modules.length == 0) {
+ return false;
+ }
+
+ uint32_t len = (uint32_t) strlen(modName);
+ if (len > 250) {
+ return false;
+ }
+
+ char temp[256];
+ temp[0] = '\n';
+ memcpy(temp + 1, modName, len);
+ temp[1 + len] = ' ';
+ return memmem(modules.chars, modules.length, temp, len + 2) != NULL;
+}