aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pies.c25
-rw-r--r--src/sysvinit.c40
2 files changed, 46 insertions, 19 deletions
diff --git a/src/pies.c b/src/pies.c
index 67ff3ee..e1a7356 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -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;

Return to:

Send suggestions and report system problems to the System administrator.