From 76424950e373d3b04ac3dd13019151bfba3e8423 Mon Sep 17 00:00:00 2001 From: sumuel Date: Mon, 17 Aug 2026 20:44:55 +0000 Subject: Add the files --- src/common/impl/kmod_linux.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/common/impl/kmod_linux.c (limited to 'src/common/impl/kmod_linux.c') 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; +} -- cgit v1.2.3