diff --git a/src/conf.c b/src/conf.c index 6160cfe2..1bdd71ae 100644 --- a/src/conf.c +++ b/src/conf.c @@ -43,23 +43,27 @@ static int parse_conf(char *file); void conf_parse_cmdline(void) { + int dbg = 0, qit = 0; FILE *fp; - char line[LINE_SIZE]; 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")) - debug = 1; + dbg = 1; - if (!debug && strstr(line, "quiet")) - quiet = 1; + if (strstr(line, "quiet")) + qit = 1; fclose(fp); } + + log_init(qit, dbg); } /* Convert optional "[!123456789S]" string into a bitmask */ diff --git a/src/log.c b/src/log.c index 93b16978..900d9be2 100644 --- a/src/log.c +++ b/src/log.c @@ -32,6 +32,14 @@ static int loglevel = LOG_NOTICE; +void log_init(int qit, int dbg) +{ + if (dbg) + debug = 1; + if (!dbg && qit) + quiet = 1; +} + /* If we enabled terse mode at boot, restore to previous setting at shutdown */ void log_exit(void) { diff --git a/src/log.h b/src/log.h index 87117e40..860cdb2e 100644 --- a/src/log.h +++ b/src/log.h @@ -40,6 +40,7 @@ #define _e(fmt, args...) logit(LOG_ERR, "%s():" fmt "\n", __func__, ##args) #define _pe(fmt, args...) logit(LOG_ERR, "%s():" fmt ": %m\n", __func__, ##args) +void log_init (int qit, int dbg); void log_exit (void); void log_debug (void);