mirror of
https://github.com/troglobit/finit.git
synced 2026-11-02 13:20:32 +00: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:
1 parent
df54f5a59c
commit
fdead062cd
3 files changed
+28
-21
No files matched your search
+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 int parse_conf(char *file);
|
||||||
static void drop_changes(void);
|
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;
|
int dbg = 0;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char line[LINE_SIZE], *cmdline, *tok;
|
char line[LINE_SIZE], *cmdline, *tok;
|
||||||
|
|
||||||
|
for (int i = 1; i < argc; i++)
|
||||||
|
parse_arg(argv[i], &dbg);
|
||||||
|
|
||||||
fp = fopen("/proc/cmdline", "r");
|
fp = fopen("/proc/cmdline", "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
goto done;
|
goto done;
|
||||||
@@ -79,19 +98,7 @@ void conf_parse_cmdline(void)
|
|||||||
|
|
||||||
while ((tok = strtok(cmdline, " \t"))) {
|
while ((tok = strtok(cmdline, " \t"))) {
|
||||||
cmdline = NULL;
|
cmdline = NULL;
|
||||||
|
parse_arg(tok, &dbg);
|
||||||
/* 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;
|
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ int conf_any_change (void);
|
|||||||
int conf_changed (char *file);
|
int conf_changed (char *file);
|
||||||
int conf_monitor (uev_ctx_t *ctx);
|
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);
|
int conf_parse_runlevels (char *runlevels);
|
||||||
void conf_parse_cond (svc_t *svc, char *cond);
|
void conf_parse_cond (svc_t *svc, char *cond);
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -292,6 +292,12 @@ int main(int argc, char *argv[])
|
|||||||
if (getpid() != 1)
|
if (getpid() != 1)
|
||||||
return client(argc, argv);
|
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
|
* Hide command line arguments from ps (in particular for
|
||||||
* forked children that don't execv()). This is an ugly
|
* forked children that don't execv()). This is an ugly
|
||||||
@@ -320,12 +326,6 @@ int main(int argc, char *argv[])
|
|||||||
chdir("/");
|
chdir("/");
|
||||||
umask(0);
|
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 */
|
/* Set up canvas */
|
||||||
if (!rescue && !log_is_debug())
|
if (!rescue && !log_is_debug())
|
||||||
screen_init();
|
screen_init();
|
||||||
|
|||||||
Reference in new issue
Block a user