Fix #352: separate runlevel S from runlevel 0

Due to an old design decision runlevel S was encoded internally as '0',
meaning it was the same as halt/poweroff.  If you want to run scripts at
system shutdown this was less then ideal since it meant your scripts
also ran at bootstrap.

This change is quite invasive.  It introduces INIT_LEVEL (10) as the
value for runlevel S, meaning all code that parses and/or evaluates
anything for runlevel 0/S was affected and had to be reworked.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-04-22 15:11:27 +02:00
1 parent 80191f2fd5
commit e00fda5dc3
12 files changed
+67 -47

No files matched your search

+7 -6
View File
@@ -48,7 +48,7 @@
#include "helpers.h"
#include "util.h"
#define BOOTSTRAP (runlevel == 0)
#define BOOTSTRAP (runlevel == INIT_LEVEL)
int logfile_size_max = 200000; /* 200 kB */
int logfile_count_max = 5;
@@ -475,7 +475,7 @@ static void kmod_load(char *mod)
char module[64] = { 0 };
char cmd[CMD_SIZE];
if (runlevel != 0)
if (runlevel != INIT_LEVEL)
return;
/* Strip args for progress below and kmod_exists() */
@@ -508,15 +508,16 @@ int conf_parse_runlevels(char *runlevels)
break;
if ('!' == lvl) {
not = 1;
bitmask = 0x3FE;
bitmask = 0x7FE;
continue;
}
if ('s' == lvl || 'S' == lvl)
lvl = '0';
level = INIT_LEVEL;
else
level = lvl - '0';
level = lvl - '0';
if (level > 9 || level < 0)
if (level > INIT_LEVEL || level < 0)
continue;
if (not)