User, modules and checkfs configurable from /etc/finit.conf

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
Claudio Matsuoka committed 2008-05-05 13:41:01 -03:00
1 parent ccd49f2024
commit c55afaadb3
4 files changed
+47 -24

No files matched your search

+41 -16
View File
@@ -137,38 +137,63 @@ int main()
mount("proc", "/proc", "proc", 0, NULL);
/*
* Parse kernel parameters
*/
if ((f = fopen("/proc/cmdline", "r")) != NULL) {
char *x;
fgets(line, LINE_SIZE, f);
if (strstr(line, "quiet")) {
close(0);
close(1);
close(2);
}
if ((x = strstr(line, "CHECKFS="))) {
x += 8;
strcpy(cmd, "e2fsck -C -p ");
c = cmd + strlen(cmd);
while (x && *x != ' ') *c++ = *x++;
system(cmd);
sync();
sync();
reboot(RB_AUTOBOOT);
}
if ((x = strstr(line, "USERNAME="))) {
x += 9;
c = cmd + strlen(cmd);
while (x && *x != ' ') *c++ = *x++;
}
if ((strstr(line, "DEBUG"))) {
debug = 1;
}
fclose(f);
}
/*
* Parse configuration file
*/
if ((f = fopen("/etc/finit.conf", "r")) != NULL) {
char *x;
while (!feof(f)) {
fgets(line, LINE_SIZE, f);
if (debug) {
printf("conf: %s", line);
}
if ((x = strstr(line, "check ")) == line) {
x += 6;
strcpy(cmd, "/sbin/e2fsck -C -p ");
c = cmd + strlen(cmd);
while (x && *x != ' ') *c++ = *x++;
system(cmd);
sync();
sync();
reboot(RB_AUTOBOOT);
}
if ((x = strstr(line, "user ")) == line) {
x += 5;
c = username;
while (x && *x != ' ') *c++ = *x++;
continue;
}
if ((x = strstr(line, "module ")) == line) {
x += 7;
strcpy(cmd, "/sbin/insmod ");
c = cmd + strlen(cmd);
while (x && *x != ' ') *c++ = *x++;
system(cmd);
continue;
}
}
fclose(f);
}
setsid();
/*