diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2014-06-11 09:34:15 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2014-06-11 09:36:00 +0300 |
commit | 7284aa23593651e26ab726d375487d3fc55a6863 (patch) | |
tree | 56a81c95ad5fd51072275f762476eaa589c28768 | |
parent | cf4ab27d35038a7e4b1d5db119729c142b15abb7 (diff) | |
download | pies-7284aa23593651e26ab726d375487d3fc55a6863.tar.gz pies-7284aa23593651e26ab726d375487d3fc55a6863.tar.bz2 |
Init emulator mode; bugfix.
* src/pies.c (main) [INIT_EMU]: Enable "init emulator" mode.
* src/sysvinit.c (enablecomp)
(sysvinit_runlevel_setup): Use struct enstate to pass information
to the callback. This fixes bug introduced by the previous commit,
which caused "wait" keyword to be ignored.
-rw-r--r-- | src/pies.c | 25 | ||||
-rw-r--r-- | src/sysvinit.c | 40 |
2 files changed, 46 insertions, 19 deletions
@@ -2232,6 +2232,15 @@ main (int argc, char **argv) set_quoting_style (NULL, shell_quoting_style); init_process = getpid () == 1; +#ifdef INIT_EMU +# warning "pies compiled with init emulation code" + if (!init_process) + { + fprintf (stderr, "%s: to enable init emulation code,\n", program_name); + fprintf (stderr, "%s: define environment variable INIT_EMU=<inittab>[:<pies_init_file>]\n", program_name); + init_process = getenv ("INIT_EMU") != NULL; + } +#endif /* Set default logging */ diag_setup (DIAG_TO_SYSLOG | (stderr_closed_p () ? 0 : DIAG_TO_STDERR)); @@ -2239,8 +2248,24 @@ main (int argc, char **argv) config_init (); if (init_process) { +#ifdef INIT_EMU + char *emu = getenv ("INIT_EMU"); + if (emu) + { + char *inittab = strtok (emu, ":"); + char *piesinit = strtok (NULL, ":"); + add_config (CONF_INITTAB, inittab); + add_config (CONF_PIES, piesinit ? piesinit : "/etc/pies.init"); + } + else + { + add_config (CONF_INITTAB, "/etc/inittab"); + add_config (CONF_PIES, "/etc/pies.init"); + } +#else add_config (CONF_INITTAB, "/etc/inittab"); add_config (CONF_PIES, "/etc/pies.init"); +#endif for (index = 1; index < argc; index++) { if (!strcmp(argv[index], "single") || !strcmp(argv[index], "-s")) diff --git a/src/sysvinit.c b/src/sysvinit.c index b2975d3..7e0dba6 100644 --- a/src/sysvinit.c +++ b/src/sysvinit.c @@ -207,22 +207,19 @@ runlevel_index (int n) return p - valid_runlevels; } +struct enstate +{ + int mask; + int wait; +}; + static int enablecomp (struct prog *prog, void *data) { - int *mask = data; - int wait; + struct enstate *s = data; int rc; struct component *comp = prog->v.p.comp; - if (mask) - { - wait = *mask & PIES_COMP_WAIT; - *mask &= ~PIES_COMP_WAIT; - } - else - wait = 0; - switch (boot_state) { case sysinit: @@ -246,21 +243,21 @@ enablecomp (struct prog *prog, void *data) case pies_comp_ondemand: case pies_comp_powerfailnow: case pies_comp_kbrequest: - return mask && (*mask & PIES_COMP_MASK (comp->mode)); + return s && (s->mask & PIES_COMP_MASK (comp->mode)); default: break; - } + } } rc = !!strchr (comp->runlevels, runlevel); if (!rc) return rc; if (prog->v.p.status == status_finished) return -1; - if (wait) + if (s && s->mask & PIES_COMP_WAIT) { if (comp->mode == pies_comp_wait) { - *mask |= PIES_COMP_WAIT; + s->wait = 1; return 1; } return 0; @@ -290,11 +287,16 @@ runlevel_setup_prog (struct prog *prog, void *data) void sysvinit_runlevel_setup (int mask, int *wait) { + struct enstate s; + s.mask = mask; if (wait) - mask |= PIES_COMP_WAIT; - progman_foreach (runlevel_setup_prog, &mask); + { + s.mask |= PIES_COMP_WAIT; + s.wait = *wait; + } + progman_foreach (runlevel_setup_prog, &s); if (wait) - *wait = mask & PIES_COMP_WAIT; + *wait = s.wait; } static const char valid_runlevel_arg[] = "0123456789SsQqAaBbCcUu"; @@ -650,11 +652,11 @@ inittrans () } if (newlevel && newlevel != runlevel) { - debug (1, ("RL TRANS: %c -> %c", runlevel, newlevel)); + prevlevel = runlevel ? runlevel : 'N'; + debug (1, ("RL TRANS: %c -> %c", prevlevel, newlevel)); sysvinit_acct (SYSV_ACCT_RUNLEVEL, "runlevel", "~~", newlevel + 256 * runlevel, "~"); mf_proctitle_format ("init [%c]", newlevel); - prevlevel = runlevel ? runlevel : 'N'; runlevel = newlevel; trans = 1; wait = 0; |