diff --git a/conf.c b/conf.c index 438f1d6e..8e20c686 100644 --- a/conf.c +++ b/conf.c @@ -71,10 +71,10 @@ int parse_runlevels(char *runlevels) } if ('s' == lvl || 'S' == lvl) - lvl = ':'; /* RUNLEVEL_BOOT */ + lvl = '0'; level = lvl - '0'; - if (level > RUNLEVEL_BOOT || level < 0) + if (level > 9 || level < 0) continue; if (not) diff --git a/finit.c b/finit.c index d38a29ee..62b95239 100644 --- a/finit.c +++ b/finit.c @@ -39,9 +39,9 @@ int debug = 0; int verbose = 1; -int runlevel = RUNLEVEL_BOOT; /* Bootstrap */ -int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */ -int prevlevel = 0; /* HALT */ +int runlevel = 0; /* Bootstrap */ +int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */ +int prevlevel = 0; /* HALT */ char *sdown = NULL; char *network = NULL; char *username = NULL; diff --git a/sig.c b/sig.c index ec11a49d..10e33ae6 100644 --- a/sig.c +++ b/sig.c @@ -110,7 +110,7 @@ static void sigstop_handler(int sig, siginfo_t *info, void *UNUSED(ctx)) _d("Received SIGSTOP(%d) from %s (PID %d)", sig, pid_get_name(info->si_pid, NULL, 0), info->si_pid); touch(SYNC_STOPPED); - stopped ++; + stopped++; } static void sigcont_handler(int sig, siginfo_t *info, void *UNUSED(ctx)) { diff --git a/svc.c b/svc.c index 00486a56..225483f1 100644 --- a/svc.c +++ b/svc.c @@ -24,6 +24,7 @@ #include #include +#include #include "finit.h" #include "helpers.h" @@ -141,6 +142,25 @@ void svc_bootstrap(void) } } +static void utmp_save(int pre, int now) +{ + struct utmp utent; + + int encode(int lvl) + { + if (!lvl) return 0; + return lvl + '0'; + } + + utent.ut_type = RUN_LVL; + utent.ut_pid = (encode(pre) << 8) | (encode(now) & 0xFF); + strlcpy(utent.ut_user, "runlevel", sizeof(utent.ut_user)); + + setutent(); + pututline(&utent); + endutent(); +} + /** * svc_runlevel - Change to a new runlevel * @newlevel: New runlevel to activate @@ -159,7 +179,8 @@ void svc_runlevel(int newlevel) return; prevlevel = runlevel; - runlevel = newlevel; + runlevel = newlevel; + utmp_save(prevlevel, newlevel); for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) { int run = svc_enabled(svc, 0, NULL); @@ -187,7 +208,7 @@ void svc_runlevel(int newlevel) else remove("/etc/nologin"); - if (RUNLEVEL_BOOT != prevlevel) + if (0 != prevlevel) tty_runlevel(runlevel); } diff --git a/svc.h b/svc.h index 1add925c..9812e151 100644 --- a/svc.h +++ b/svc.h @@ -42,7 +42,6 @@ typedef enum { SVC_CMD_RUN /* Like task, but wait for completion */ } svc_type_t; -#define RUNLEVEL_BOOT 10 #define FINIT_SHM_ID 0x494E4954 /* "INIT", see ascii(7) */ #define MAX_ARG_LEN 64 #define MAX_STR_LEN 64