diff options
author | NeilBrown <neilb@suse.de> | 2013-09-03 05:25:02 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-09-03 05:25:02 +0200 |
commit | 2dfb675b94852f4a1a4ec24528292dd0e8f96c89 (patch) | |
tree | 81420f1b9d03b52cadd19f65acbe833e3cfd737d /config.c | |
parent | config: refactor load_conffile() to have a single exit. (diff) | |
download | mdadm-2dfb675b94852f4a1a4ec24528292dd0e8f96c89.tar.xz mdadm-2dfb675b94852f4a1a4ec24528292dd0e8f96c89.zip |
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.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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; } |