diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-06-24 12:56:24 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-06-24 12:56:24 +0300 |
commit | 006bfbc5235c181783445d321ce7a7e3c6d8bd8a (patch) | |
tree | f483e0d30c3e801add01b372b24a342281b70b86 /src/sysvinit.c | |
parent | cb90ca582a46ef9f0779837dc4c6fb00656e70c9 (diff) | |
download | pies-006bfbc5235c181783445d321ce7a7e3c6d8bd8a.tar.gz pies-006bfbc5235c181783445d321ce7a7e3c6d8bd8a.tar.bz2 |
Enable/disable SystemV init code at compile time
* configure.ac: New option --enable-sysvinit. Disable the init
code if RUN_LVL is not available.
(PIES_SYSVINIT_ENABLED): New configuration define.
(PIES_COND_SYSVINIT): New condition
Print configuration settings summary.
* src/pies.h (is_sysvinit): Check for PIES_SYSVINIT_ENABLED.
(SYSVINIT_ACTIVE): New macro.
* grecs: Upgrade.
* src/Makefile.am: Conditionally link sysvinit-related code.
* src/cmdline.opt: Disable the --telinit option if sysvinit support
is not available.
(parse_options): Use SYSVINIT_ACTIVE in the conditional.
* src/comp.c (component_verify): Check if component definition is
allowed by the current state of the sysvinit support.
* src/ctl.c: Disable the /runlevel entry point if sysvinit support
is not compiled.
* src/diag.c (stderr_open): Make sure sysvinit-related code is not
compiled if the sysvinit support is not available.
* src/pies.c (config_syntax_tab): Add entry for CONF_INITTAB only if
sysvinit support is available.
(_cb_initdefault,_cb_runlevels): Remove. Use cb_initdefault and cb_runlevels
instead.
(component_keywords): Disable runlevels without sysvinit support.
(pies_keywords): Same for initdefault.
Use SYSVINIT_ACTIVE to suppress compilation of sysvinit code without
sysvinit support.
* src/progman.c: Use SYSVINIT_ACTIVE to suppress compilation of
sysvinit code without sysvinit support.
* src/sysvinit.c (cb_initdefault,cb_runlevels): New functions.
Diffstat (limited to 'src/sysvinit.c')
-rw-r--r-- | src/sysvinit.c | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/src/sysvinit.c b/src/sysvinit.c index 3ba986b..c5d25da 100644 --- a/src/sysvinit.c +++ b/src/sysvinit.c @@ -55,13 +55,13 @@ static int boot_trans_tab[max_boot_state][sizeof(valid_runlevels)-1] = { }; enum boot_state boot_state; -int runlevel = 0; -int prevlevel = 'N'; +static int runlevel = 0; +static int prevlevel = 'N'; -int initdefault; /* Default runlevel */ -int dfl_level; -char *emergency_shell = EMERGENCY_SHELL; -int emergency; +int initdefault; +static int dfl_level; +static char *emergency_shell = EMERGENCY_SHELL; +static int emergency; static int inittrans (void); @@ -340,7 +340,7 @@ is_valid_runlevel (int c) { return !!strchr (valid_runlevel_arg, c); } - + #define ENVAR_CONSOLE "CONSOLE=" #define ENVTMPL_CONSOLE "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" @@ -1283,3 +1283,53 @@ sysvinit_parse_argv (int argc, char **argv) dfl_level = c; } } + +int +cb_initdefault (enum grecs_callback_command cmd, + grecs_node_t *node, + void *varptr, void *cb_data) +{ + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; + + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) + return 1; + if (strlen (value->v.string) != 1) + { + grecs_error (locus, 0, _("argument must be a single character")); + return 1; + } + if (!is_valid_runlevel (value->v.string[0])) + { + grecs_error (locus, 0, _("not a valid runlevel")); + return 1; + } + initdefault = toupper (value->v.string[0]); + return 0; +} + +int +cb_runlevels (enum grecs_callback_command cmd, + grecs_node_t *node, + void *varptr, void *cb_data) +{ + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; + char **sptr = varptr, *p; + + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) + return 1; + for (p = value->v.string; *p; p++) + { + if (!is_valid_runlevel (*p)) + { + grecs_error (locus, 0, _("not a valid runlevel: %c"), *p); + return 1; + } + } + *sptr = grecs_strdup (value->v.string); + for (p = *sptr; *p; p++) + *p = toupper (*p); + return 0; +} + |