diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-22 12:31:56 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-22 12:33:46 +0200 |
commit | bfa3617a79292e3569587c65cd218b69bdfd28a2 (patch) | |
tree | 8b094ec15dbb50be7324b3aa2f0d7486146a04d3 /src | |
parent | a9bd91de478ab29fa7bac2093479a1ccee1bbd87 (diff) | |
download | pies-bfa3617a79292e3569587c65cd218b69bdfd28a2.tar.gz pies-bfa3617a79292e3569587c65cd218b69bdfd28a2.tar.bz2 |
Provide a default single-user entry in init mode
This complements 6aac230c. The entry is created unless
a component for runlevel S already exists.
* src/comp.c (component_foreach): New function.
* src/pies.h: Likewise.
* src/sysvinit.c (inittab_parse): Provide default S
entry unless one is already defined.
Diffstat (limited to 'src')
-rw-r--r-- | src/comp.c | 17 | ||||
-rw-r--r-- | src/pies.h | 2 | ||||
-rw-r--r-- | src/sysvinit.c | 14 |
3 files changed, 29 insertions, 4 deletions
@@ -812,6 +812,23 @@ component_depmap_next (pies_depmap_pos_t pos) | |||
812 | return NULL; | 812 | return NULL; |
813 | return comp_array[n]; | 813 | return comp_array[n]; |
814 | } | 814 | } |
815 | |||
816 | int | ||
817 | component_foreach (int (*filter) (struct component *, void *), void *data) | ||
818 | { | ||
819 | struct component *comp; | ||
820 | int rc = 0; | ||
821 | struct complist *list = &comp_list[cur]; | ||
822 | |||
823 | for (comp = list->head; comp; ) | ||
824 | { | ||
825 | struct component *next = comp->next; | ||
826 | if ((rc = filter (comp, data)) != 0) | ||
827 | break; | ||
828 | comp = next; | ||
829 | } | ||
830 | return rc; | ||
831 | } | ||
815 | 832 | ||
816 | 833 | ||
817 | 834 | ||
@@ -406,6 +406,8 @@ int component_is_active (struct component *comp); | |||
406 | 406 | ||
407 | void component_finish (struct component *comp, grecs_locus_t *locus); | 407 | void component_finish (struct component *comp, grecs_locus_t *locus); |
408 | struct grecs_keyword *find_component_keyword (const char *ident); | 408 | struct grecs_keyword *find_component_keyword (const char *ident); |
409 | int component_foreach (int (*filter) (struct component *, void *), | ||
410 | void *data); | ||
409 | 411 | ||
410 | void components_dump_depmap (void); | 412 | void components_dump_depmap (void); |
411 | void components_trace (char **argv, enum pies_depmap_direction dir); | 413 | void components_trace (char **argv, enum pies_depmap_direction dir); |
diff --git a/src/sysvinit.c b/src/sysvinit.c index 695a22a..cc26fa9 100644 --- a/src/sysvinit.c +++ b/src/sysvinit.c | |||
@@ -1092,6 +1092,13 @@ inittab_parse_line (struct inittab_ctx *ctx) | |||
1092 | return inittab_ok; | 1092 | return inittab_ok; |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | /* Return true if we hit a single-user component */ | ||
1096 | static int | ||
1097 | is_single_user (struct component *comp, void *data) | ||
1098 | { | ||
1099 | return is_sysvinit (comp) && comp->runlevels && strchr (comp->runlevels, 'S'); | ||
1100 | } | ||
1101 | |||
1095 | int | 1102 | int |
1096 | inittab_parse (const char *file) | 1103 | inittab_parse (const char *file) |
1097 | { | 1104 | { |
@@ -1125,13 +1132,12 @@ inittab_parse (const char *file) | |||
1125 | err = 1; | 1132 | err = 1; |
1126 | } | 1133 | } |
1127 | 1134 | ||
1128 | if (component_list_is_empty ()) | 1135 | if (!component_foreach (is_single_user, 0)) |
1129 | { | 1136 | { |
1130 | /* Provide default inittab entry */ | 1137 | /* Provide single-user entry */ |
1131 | ctx.file = __FILE__; | 1138 | ctx.file = __FILE__; |
1132 | ctx.line_no = __LINE__; | 1139 | ctx.line_no = __LINE__; |
1133 | grecs_asprintf (&ctx.buf, &ctx.size, "~~:%s:wait:%s\n", | 1140 | grecs_asprintf (&ctx.buf, &ctx.size, "~~:S:wait:%s\n", emergency_shell); |
1134 | valid_runlevels, emergency_shell); | ||
1135 | inittab_parse_line (&ctx); | 1141 | inittab_parse_line (&ctx); |
1136 | } | 1142 | } |
1137 | 1143 | ||