Files
fastfetch/src/common/impl/kmod_linux.c
T

26 lines
592 B
C
Raw Normal View History

2026-03-01 14:01:18 +08:00
#include "common/kmod.h"
#include "common/io.h"
2026-03-29 09:28:49 +08:00
bool ffKmodLoaded(const char* modName) {
2026-03-01 14:01:18 +08:00
static FFstrbuf modules;
2026-07-10 18:08:04 +08:00
if (modules.chars == nullptr) {
2026-03-01 14:01:18 +08:00
ffStrbufInitS(&modules, "\n");
ffAppendFileBuffer("/proc/modules", &modules);
}
2026-03-29 09:28:49 +08:00
if (modules.length == 0) {
return false;
}
2026-03-01 14:01:18 +08:00
uint32_t len = (uint32_t) strlen(modName);
2026-03-29 09:28:49 +08:00
if (len > 250) {
return false;
}
2026-03-01 14:01:18 +08:00
char temp[256];
temp[0] = '\n';
memcpy(temp + 1, modName, len);
temp[1 + len] = ' ';
2026-07-10 18:08:04 +08:00
return memmem(modules.chars, modules.length, temp, len + 2) != nullptr;
2026-03-01 14:01:18 +08:00
}