aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-02-22 12:31:56 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-02-22 12:33:46 +0200
commitbfa3617a79292e3569587c65cd218b69bdfd28a2 (patch)
tree8b094ec15dbb50be7324b3aa2f0d7486146a04d3 /src
parenta9bd91de478ab29fa7bac2093479a1ccee1bbd87 (diff)
downloadpies-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.c17
-rw-r--r--src/pies.h2
-rw-r--r--src/sysvinit.c14
3 files changed, 29 insertions, 4 deletions
diff --git a/src/comp.c b/src/comp.c
index 38e440e..43772c2 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -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
816int
817component_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
diff --git a/src/pies.h b/src/pies.h
index 939bd4c..d4b5c6a 100644
--- a/src/pies.h
+++ b/src/pies.h
@@ -406,6 +406,8 @@ int component_is_active (struct component *comp);
406 406
407void component_finish (struct component *comp, grecs_locus_t *locus); 407void component_finish (struct component *comp, grecs_locus_t *locus);
408struct grecs_keyword *find_component_keyword (const char *ident); 408struct grecs_keyword *find_component_keyword (const char *ident);
409int component_foreach (int (*filter) (struct component *, void *),
410 void *data);
409 411
410void components_dump_depmap (void); 412void components_dump_depmap (void);
411void components_trace (char **argv, enum pies_depmap_direction dir); 413void 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 */
1096static int
1097is_single_user (struct component *comp, void *data)
1098{
1099 return is_sysvinit (comp) && comp->runlevels && strchr (comp->runlevels, 'S');
1100}
1101
1095int 1102int
1096inittab_parse (const char *file) 1103inittab_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

Return to:

Send suggestions and report system problems to the System administrator.