mirror of
https://github.com/troglobit/finit.git
synced 2026-10-03 06:23:11 +07:00
Support reading --debug et al from process command line
Up until now Finit has only read /proc/cmdline to determine debug level, single user mode, etc. This patch is one in a series to make enable it to run also in containers. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+21
-14
@@ -59,12 +59,31 @@ static TAILQ_HEAD(head, conf_change) conf_change_list = TAILQ_HEAD_INITIALIZER(c
|
||||
static int parse_conf(char *file);
|
||||
static void drop_changes(void);
|
||||
|
||||
void conf_parse_cmdline(void)
|
||||
static void parse_arg(char *arg, int *dbg)
|
||||
{
|
||||
/* Catches finit_debug (deprecated), --debug, and debug */
|
||||
if (strstr(arg, "debug"))
|
||||
*dbg = 1;
|
||||
|
||||
if (string_compare(arg, "rescue") || string_compare(arg, "recover"))
|
||||
rescue = 1;
|
||||
|
||||
if (string_compare(arg, "single") || string_compare(arg, "S"))
|
||||
single = 1;
|
||||
|
||||
if (string_compare(arg, "splash"))
|
||||
splash = 1;
|
||||
}
|
||||
|
||||
void conf_parse_cmdline(int argc, char *argv[])
|
||||
{
|
||||
int dbg = 0;
|
||||
FILE *fp;
|
||||
char line[LINE_SIZE], *cmdline, *tok;
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
parse_arg(argv[i], &dbg);
|
||||
|
||||
fp = fopen("/proc/cmdline", "r");
|
||||
if (!fp)
|
||||
goto done;
|
||||
@@ -79,19 +98,7 @@ void conf_parse_cmdline(void)
|
||||
|
||||
while ((tok = strtok(cmdline, " \t"))) {
|
||||
cmdline = NULL;
|
||||
|
||||
/* Catches finit_debug (deprecated), --debug, and debug */
|
||||
if (strstr(tok, "debug"))
|
||||
dbg = 1;
|
||||
|
||||
if (string_compare(tok, "rescue") || string_compare(tok, "recover"))
|
||||
rescue = 1;
|
||||
|
||||
if (string_compare(tok, "single") || string_compare(tok, "S"))
|
||||
single = 1;
|
||||
|
||||
if (string_compare(tok, "splash"))
|
||||
splash = 1;
|
||||
parse_arg(tok, &dbg);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ int conf_any_change (void);
|
||||
int conf_changed (char *file);
|
||||
int conf_monitor (uev_ctx_t *ctx);
|
||||
|
||||
void conf_parse_cmdline (void);
|
||||
void conf_parse_cmdline (int argc, char *argv[]);
|
||||
int conf_parse_runlevels (char *runlevels);
|
||||
void conf_parse_cond (svc_t *svc, char *cond);
|
||||
|
||||
|
||||
+6
-6
@@ -292,6 +292,12 @@ int main(int argc, char *argv[])
|
||||
if (getpid() != 1)
|
||||
return client(argc, argv);
|
||||
|
||||
/*
|
||||
* Parse kernel command line (debug, rescue, splash, etc.)
|
||||
* Also calls log_init() to set correct log level
|
||||
*/
|
||||
conf_parse_cmdline(argc, argv);
|
||||
|
||||
/*
|
||||
* Hide command line arguments from ps (in particular for
|
||||
* forked children that don't execv()). This is an ugly
|
||||
@@ -320,12 +326,6 @@ int main(int argc, char *argv[])
|
||||
chdir("/");
|
||||
umask(0);
|
||||
|
||||
/*
|
||||
* Parse kernel command line (debug, rescue, splash, etc.)
|
||||
* Also calls log_init() to set correct log level
|
||||
*/
|
||||
conf_parse_cmdline();
|
||||
|
||||
/* Set up canvas */
|
||||
if (!rescue && !log_is_debug())
|
||||
screen_init();
|
||||
|
||||
Reference in New Issue
Block a user