summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2016-01-31 14:40:27 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2016-01-31 14:40:27 (GMT)
commitd9d267052215f223897af18310e4adee310308e7 (patch) (side-by-side diff)
tree6b6f9eb636975f5721e00d2d71007185fa5b2fbf
parent6f9f2fd7a6952b544dccbf0bdc7f9c312f602afe (diff)
downloadpies-d9d267052215f223897af18310e4adee310308e7.tar.gz
pies-d9d267052215f223897af18310e4adee310308e7.tar.bz2
Support sysvinit ondemand components.
* src/ctl.c (fun_start): Handle status_finished same as status_sleeping (for restarting ondemand components). * src/progman.c: Respawn ondemand components. * src/sysvinit.c (enablecomp): Handle pies_comp_ondemand. (sysvinit_demand): New function. (sysvinit_fifo_handler): Handle ondemand runlevels. (inittab_parse): Support "off" fields. Convert runlevels to upper case.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--src/ctl.c16
-rw-r--r--src/progman.c5
-rw-r--r--src/sysvinit.c60
3 files changed, 66 insertions, 15 deletions
diff --git a/src/ctl.c b/src/ctl.c
index 0e5ea97..489fc7f 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -1878,4 +1878,5 @@ fun_start (struct json_value *result, struct prog *prog)
{
- if (prog->v.p.status == status_disabled)
+ switch (prog->v.p.status)
{
+ case status_disabled:
prog->v.p.comp->flags &= ~CF_DISABLED;
@@ -1883,5 +1884,6 @@ fun_start (struct json_value *result, struct prog *prog)
json_object_set_string (result, "status", "OK");
- }
- else if (prog->v.p.status == status_sleeping)
- {
+ break;
+
+ case status_sleeping:
+ case status_finished:
prog->v.p.status = status_enabled;
@@ -1890,5 +1892,5 @@ fun_start (struct json_value *result, struct prog *prog)
json_object_set_string (result, "status", "OK");
- }
- else
- {
+ break;
+
+ default:
json_object_set_string (result, "status", "ER");
diff --git a/src/progman.c b/src/progman.c
index 4ca3824..020dccd 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -305,3 +305,3 @@ progman_waiting_p ()
{
- debug(1, ("%s: waiting for %s (%lu)",
+ debug (3, ("%s: waiting for %s (%lu)",
__FUNCTION__, prog_tag (prog),
@@ -2307,3 +2307,4 @@ progman_cleanup (int expect_term)
{
- if (prog->v.p.comp->mode >= pies_mark_sysvinit)
+ if (prog->v.p.comp->mode >= pies_mark_sysvinit
+ && prog->v.p.comp->mode != pies_comp_ondemand)
{
diff --git a/src/sysvinit.c b/src/sysvinit.c
index be7aef8..337b922 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -240,2 +240,6 @@ enablecomp (struct prog *prog, void *data)
return 0;
+
+ case pies_comp_ondemand:
+ return prog->v.p.status == status_enabled;
+
case pies_comp_powerfail:
@@ -244,3 +248,2 @@ enablecomp (struct prog *prog, void *data)
case pies_comp_ctrlaltdel:
- case pies_comp_ondemand:
case pies_comp_powerfailnow:
@@ -303,2 +306,23 @@ sysvinit_runlevel_setup (int mask, int *wait)
+static int
+demand_prog (struct prog *prog, void *data)
+{
+ int *rl = data;
+ struct component *comp = prog->v.p.comp;
+ if (comp->mode == pies_comp_ondemand
+ && comp->runlevels
+ && strchr (comp->runlevels, *rl))
+ {
+ prog->v.p.status = status_enabled;
+ debug (1, ("%s: %s", prog_tag (prog), "enabled"));
+ }
+ return 0;
+}
+
+static void
+sysvinit_demand (int rl)
+{
+ progman_foreach (demand_prog, &rl);
+}
+
static const char valid_runlevel_arg[] = "0123456789SsQqAaBbCcUu";
@@ -460,2 +484,13 @@ sysvinit_fifo_handler (int fd, void *data)
{
+ switch (buf.req.runlevel)
+ {
+ case 'A':
+ case 'B':
+ case 'C':
+ sysvinit_demand (buf.req.runlevel);
+ break;
+
+ default:
+ if (runlevel_index (buf.req.runlevel) != -1)
+ {
dfl_level = buf.req.runlevel;
@@ -464,2 +499,4 @@ sysvinit_fifo_handler (int fd, void *data)
}
+ }
+ }
break;
@@ -848,2 +885,11 @@ find_action_parser (const char *action)
+static char *
+strupr (char *s)
+{
+ char *p;
+ for (p = s; *p; p++)
+ *p = toupper (*p);
+ return s;
+}
+
int
@@ -933,4 +979,3 @@ inittab_parse (const char *file)
{
- logmsg (LOG_ERR, "%s:%u: %s",
- file, line_no, _("not enough fields"));
+ logmsg (LOG_ERR, "%s:%u: %s", file, line_no, _("not enough fields"));
err = 1;
@@ -952,2 +997,6 @@ inittab_parse (const char *file)
+ if (strcmp (action, "off") == 0)
+ /* Ignore the entry */
+ continue;
+
ap = find_action_parser (action);
@@ -955,4 +1004,3 @@ inittab_parse (const char *file)
{
- logmsg (LOG_ERR, "%s:%u: %s",
- file, line_no, _("unknown action"));
+ logmsg (LOG_ERR, "%s:%u: %s", file, line_no, _("unknown action"));
err = 1;
@@ -963,3 +1011,3 @@ inittab_parse (const char *file)
comp->mode = ap->mode;
- comp->runlevels = grecs_strdup (runlevels);
+ comp->runlevels = grecs_strdup (strupr (runlevels));

Return to:

Send suggestions and report system problems to the System administrator.