mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 05:52:48 +07:00
Refactor conf_parse_cmdline(), support 'debug' as well as '--debug'
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+18
-9
@@ -58,21 +58,30 @@ void conf_parse_cmdline(void)
|
||||
{
|
||||
int dbg = 0;
|
||||
FILE *fp;
|
||||
char line[LINE_SIZE], *cmdline, *tok;
|
||||
|
||||
fp = fopen("/proc/cmdline", "r");
|
||||
if (fp) {
|
||||
char line[LINE_SIZE];
|
||||
|
||||
fgets(line, sizeof(line), fp);
|
||||
chomp(line);
|
||||
_d("%s", line);
|
||||
|
||||
if (strstr(line, "finit_debug") || strstr(line, "--debug"))
|
||||
dbg = 1;
|
||||
if (!fp)
|
||||
goto done;
|
||||
|
||||
if (!fgets(line, sizeof(line), fp)) {
|
||||
fclose(fp);
|
||||
goto done;
|
||||
}
|
||||
|
||||
cmdline = chomp(line);
|
||||
_d("%s", cmdline);
|
||||
|
||||
while ((tok = strtok(cmdline, " \t"))) {
|
||||
cmdline = NULL;
|
||||
|
||||
/* Catches finit_debug (deprecated), --debug, and debug */
|
||||
if (strstr(tok, "debug"))
|
||||
dbg = 1;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
done:
|
||||
log_init(dbg);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -366,7 +366,8 @@ int main(int argc, char* argv[])
|
||||
mount("none", "/proc/bus/usb", "usbfs", 0, NULL);
|
||||
|
||||
/*
|
||||
* Parse kernel parameters, including log_init()
|
||||
* Parse kernel command line (debug, rescue, splash, etc.)
|
||||
* Also calls log_init() to set correct log level
|
||||
*/
|
||||
conf_parse_cmdline();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user