aboutsummaryrefslogtreecommitdiff
path: root/src/sysvinit.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2016-02-13 12:48:59 +0200
committerSergey Poznyakoff <gray@gnu.org>2016-02-13 12:48:59 +0200
commit3c774556e22cd30c42304614e14218a767e4d700 (patch)
treecdcc278f470b2ef8863cf10655315f8579f679b2 /src/sysvinit.c
parent92145d8331e824a54109c53032f0ca4b2df71f5f (diff)
downloadpies-3c774556e22cd30c42304614e14218a767e4d700.tar.gz
pies-3c774556e22cd30c42304614e14218a767e4d700.tar.bz2
Implement on-demaind components; implement control socket telinit interface.
* src/pies.h: Include json.h (sysvinit_report, sysvinit_set_runlevel) (json_object_set_string, json_object_set_number): New protos. * src/ctl.c (ctlio_resource)<predicate>: New member. (restab): New endpoint: runlevel. Available only if run as pid 1. (find_resource): If predicate is not NULL, call it to confirm that the endpoint is available. * src/piesctl.c: New subcommand "telinit". * src/sysvinit.c (sysvinit_set_runlevel): New function. (sysvinit_fifo_handler): Implement on-demaind components.
Diffstat (limited to 'src/sysvinit.c')
-rw-r--r--src/sysvinit.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/src/sysvinit.c b/src/sysvinit.c
index 337b922..9e918c7 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -425,6 +425,33 @@ sysvinit_setenv (char const *data, int size)
}
}
+int
+sysvinit_set_runlevel (int newlevel)
+{
+ switch (newlevel)
+ {
+ case 'A':
+ case 'B':
+ case 'C':
+ sysvinit_demand (newlevel);
+ break;
+
+ default:
+ if (newlevel == runlevel)
+ {
+ }
+ if (runlevel_index (newlevel) == -1)
+ return -1;
+ else
+ {
+ dfl_level = newlevel;
+ inittrans ();
+ }
+ }
+ return 0;
+}
+
+
char *init_fifo = INIT_FIFO;
static void create_fifo (void);
@@ -480,24 +507,7 @@ sysvinit_fifo_handler (int fd, void *data)
break;
default:
- if (buf.req.runlevel != runlevel)
- {
- 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;
- inittrans ();
- }
- }
- }
+ sysvinit_set_runlevel (buf.req.runlevel);
}
break;
@@ -1097,3 +1107,15 @@ powerfailcmd (int power_stat)
sysvinit_runlevel_setup (mask, NULL);
}
+
+void
+sysvinit_report (struct json_value *obj)
+{
+ json_object_set_string (obj, "runlevel", "%c", runlevel);
+ json_object_set_string (obj, "prevlevel", "%c", prevlevel);
+ json_object_set_string (obj, "bootstate", "%s",
+ boot_state_name[boot_state]);
+ if (initdefault)
+ json_object_set_string (obj, "initdefault", "%c",
+ initdefault);
+}

Return to:

Send suggestions and report system problems to the System administrator.