diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2019-04-16 11:53:30 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2019-04-16 11:53:30 +0000 |
commit | 5199738f4e32773f4f752a94998593e18e3af36f (patch) | |
tree | da873d981d6533dd32101d1ce91f299c9bf47bab /src/state | |
parent | 16937b000b68477aabafe429520529108ed9f334 (diff) | |
download | s6-linux-init-5199738f4e32773f4f752a94998593e18e3af36f.tar.xz |
Small fixes before reorganizing
Diffstat (limited to 'src/state')
-rw-r--r-- | src/state/s6-linux-init-shutdown.c | 1 | ||||
-rw-r--r-- | src/state/s6-linux-init-shutdownd.c | 43 |
2 files changed, 3 insertions, 41 deletions
diff --git a/src/state/s6-linux-init-shutdown.c b/src/state/s6-linux-init-shutdown.c index eb65d1d..bb0391d 100644 --- a/src/state/s6-linux-init-shutdown.c +++ b/src/state/s6-linux-init-shutdown.c @@ -8,7 +8,6 @@ #include <errno.h> #include <time.h> #include <utmpx.h> -#include <sys/reboot.h> #include <skalibs/uint32.h> #include <skalibs/types.h> diff --git a/src/state/s6-linux-init-shutdownd.c b/src/state/s6-linux-init-shutdownd.c index d4ecd4b..e330ac6 100644 --- a/src/state/s6-linux-init-shutdownd.c +++ b/src/state/s6-linux-init-shutdownd.c @@ -45,30 +45,11 @@ static inline void prepare_shutdown (char c, unsigned int *what, tain_t *deadlin tain_unpack(pack, deadline) ; uint32_unpack_big(pack + TAIN_PACK, &u) ; if (u && u <= 300000) *grace_time = u ; - *what = byte_chr(" hpr", c, 4) ; -} - -static inline void change_runlevels (char c) -{ - pid_t pid = doublefork() ; - if (pid == -1) - strerr_warnwu1sys("doublefork for runlevel change") ; - if (pid) - { - size_t basedirlen = strlen(basedir) ; - char fn[basedirlen + sizeof("/scripts/runlevel")] ; - char s[2] = { c, 0 } ; - char const *cargv[3] = { fn, s, 0 } ; - PROG = "s6-linux-init-shutdownd (grandchild)" ; - memcpy(fn, basedir, basedirlen) ; - memcpy(fn + basedirlen, "/scripts/runlevel", sizeof("/scripts/runlevel")) ; - xpathexec_run(cargv[0], cargv, (char const *const *)environ) ; - } + *what = 1 + byte_chr("hpr", c, 3) ; } static inline void handle_stdin (unsigned int *what, tain_t *deadline, unsigned int *grace_time) { - char rl = 0 ; for (;;) { char c ; @@ -84,23 +65,7 @@ static inline void handle_stdin (unsigned int *what, tain_t *deadline, unsigned break ; case 'c' : *what = 0 ; - rl = 0 ; - tain_add_g(deadline, &tain_infinite_relative) ; - break ; - case 'S' : - *what = 4 ; - tain_copynow(deadline) ; - break ; - case '0' : - case '1' : - case '2' : - case '3' : - case '4' : - case '5' : - case '6' : - *what = 0 ; tain_add_g(deadline, &tain_infinite_relative) ; - rl = c ; break ; default : { @@ -110,12 +75,11 @@ static inline void handle_stdin (unsigned int *what, tain_t *deadline, unsigned break ; } } - if (rl) change_runlevels(rl) ; } static inline void prepare_stage4 (char const *bindir, char const *basedir, unsigned int what) { - static char const *table[4] = { "single", "halt", "poweroff", "reboot" } ; + static char const *table[3] = { "halt", "poweroff", "reboot" } ; stralloc sa = STRALLOC_ZERO ; buffer b ; char buf[512] ; @@ -133,7 +97,7 @@ static inline void prepare_stage4 (char const *bindir, char const *basedir, unsi strerr_diefu1sys(111, "string_quote") ; if (buffer_put(&b, sa.s, sa.len) == -1 || buffer_puts(&b, "/bin/" STAGE4 " ") == -1 - || buffer_puts(&b, table[what]) == -1 + || buffer_puts(&b, table[what-1]) == -1 || buffer_putsflush(&b, "\n") == -1) strerr_diefu2sys(111, "write to ", STAGE4_FILE ".new") ; stralloc_free(&sa) ; @@ -213,7 +177,6 @@ int main (int argc, char const *const *argv) handle_stdin(&what, &deadline, &grace_time) ; } - if (what == 4) what = 0 ; /* Stage 3 */ |