summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-09-03 13:25:02 +1000
committerNeilBrown <neilb@suse.de>2013-09-03 13:25:02 +1000
commit2dfb675b94852f4a1a4ec24528292dd0e8f96c89 (patch)
tree81420f1b9d03b52cadd19f65acbe833e3cfd737d /config.c
parent824e57276a32684a32ef4d36c0caddd1d2b9b2a2 (diff)
config: support MDADM_CONF_AUTO= env var.
If a distribution allows the choice between using mdadm and dmraid for DDF and IMSM to be made by some config file (/etc/defaults/ /sys/sysconfig/ etc) which is queried by /etc/init.d scripts, then the fact that mdadm implements this choce through the config file is not very helpful. So allow the "AUTO" line to be specified in part using MDADM_CONF_AUTO in environment. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'config.c')
-rw-r--r--config.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/config.c b/config.c
index edadf02a..f1a70c59 100644
--- a/config.c
+++ b/config.c
@@ -602,6 +602,24 @@ void autoline(char *line)
* been seen gets an appropriate auto= entry.
*/
+ /* If environment variable MDADM_CONF_AUTO is defined, then
+ * it is prepended to the auto line. This allow a script
+ * to easily disable some metadata types.
+ */
+ w = getenv("MDADM_CONF_AUTO");
+ if (w && *w) {
+ char *l = xstrdup(w);
+ char *head = line;
+ w = strtok(l, " \t");
+ while (w) {
+ char *nw = dl_strdup(w);
+ dl_insert(head, nw);
+ head = nw;
+ w = strtok(NULL, " \t");
+ }
+ free(l);
+ }
+
for (super_cnt = 0; superlist[super_cnt]; super_cnt++)
;
seen = xcalloc(super_cnt, 1);
@@ -783,6 +801,7 @@ void load_conffile(void)
{
FILE *f;
char *confdir = NULL;
+ char *head;
if (loaded)
return;
@@ -824,6 +843,14 @@ void load_conffile(void)
}
}
}
+ /* If there was no AUTO line, process an empty line
+ * now so that the MDADM_CONF_AUTO env var gets processed.
+ */
+ head = dl_strdup("AUTO");
+ dl_init(head);
+ autoline(head);
+ free_line(head);
+
loaded = 1;
}