]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
config: support MDADM_CONF_AUTO= env var.
authorNeilBrown <neilb@suse.de>
Tue, 3 Sep 2013 03:25:02 +0000 (13:25 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 3 Sep 2013 03:25:02 +0000 (13:25 +1000)
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>
config.c
mdadm.8.in

index edadf02a6859a19e83f176b8f7e6b76d62963625..f1a70c59f971575212a2c4d1937f6c586316b6f1 100644 (file)
--- 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;
 }
 
index fbb37c63e12bf25fce3b579e324bb67b74824176..ef05233c204560da703e16f7cc391a5d1851dadd 100644 (file)
@@ -2838,6 +2838,28 @@ These checks can be suppressed by setting IMSM_NO_PLATFORM=1 in the
 environment.  This can be useful for testing or for disaster
 recovery.  You should be aware that interoperability may be
 compromised by setting this value.
+
+.TP
+.B MDADM_CONF_AUTO
+Any string given in this variable is added to the start of the
+.B AUTO
+line in the config file, or treated as the whole
+.B AUTO
+line if none is given.  It can be used to disable certain metadata
+types when
+.I mdadm
+is called from a boot script.  For example
+.br
+.B "    export MDADM_CONF_AUTO='-ddf -imsm'
+.br
+will make sure that
+.I mdadm
+does not automatically assemble any DDF or
+IMSM arrays that are found.  This can be useful on systems configured
+to manage such arrays with
+.BR dmraid .
+
+
 .SH EXAMPLES
 
 .B "  mdadm \-\-query /dev/name-of-device"