mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
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:
9 files changed
+831
-826
No files matched your search
@@ -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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user