conf: cleanup and relocation of common parsing functions and helpers

- legacy.[ch]: strictly legacy .conf parser boilerplate only
 - conf.[ch]: .conf parser and generic configuration functionality

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-07-30 15:21:26 +02:00
1 parent c20d64587c
commit 47a18140c1
9 files changed
+831 -826

No files matched your search

+46
View File
@@ -470,6 +470,52 @@ done:
}
}
static int kmod_exists(const char *mod)
{
char buf[256];
int found = 0;
FILE *fp;
fp = fopen("/proc/modules", "r");
if (!fp)
return 0;
while (!found && fgets(buf, sizeof(buf), fp)) {
const char *kmod = strtok(buf, " \t");
if (kmod && !strcmp(kmod, mod))
found = 1;
}
fclose(fp);
return found;
}
/*
* Load a kernel module during bootstrap
*/
void kmod_load(char *mod)
{
char module[64] = { 0 };
char cmd[CMD_SIZE];
if (runlevel != INIT_LEVEL)
return;
/* Strip args for progress below and kmod_exists() */
strlcpy(module, mod, sizeof(module));
if (!strtok(module, " \t"))
return;
if (kmod_exists(module))
return;
strcpy(cmd, "modprobe ");
strlcat(cmd, mod, sizeof(cmd));
run_interactive(cmd, "Loading kernel module %s", module);
}
/*
* Bring up networking, but only if not single-user or rescue mode
*/