Refactor conf_parse_cmdline(), support 'debug' as well as '--debug'

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-12-30 21:19:55 +01:00
parent 925212f7cf
commit db3263c441
2 changed files with 20 additions and 10 deletions
+18 -9
View File
@@ -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
View File
@@ -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();