]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - config.c
Manage: Remove unnecessary NULL pointer checks
[thirdparty/mdadm.git] / config.c
index a882ed33fe9d26dfebbd470e926207f52cc311aa..b308b6cc5bac58fb42cbde97f35d83595be4b9d2 100644 (file)
--- a/config.c
+++ b/config.c
@@ -63,6 +63,9 @@
  * but may not wrap over lines
  *
  */
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#endif
 
 #ifndef CONFFILE
 #define CONFFILE "/etc/mdadm.conf"
@@ -77,7 +80,7 @@ char DefaultAltConfFile[] = CONFFILE2;
 char DefaultAltConfDir[] = CONFFILE2 ".d";
 
 enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev,
-               Homehost, AutoMode, Policy, PartPolicy, LTEnd };
+               Homehost, HomeCluster, AutoMode, Policy, PartPolicy, LTEnd };
 char *keywords[] = {
        [Devices]  = "devices",
        [Array]    = "array",
@@ -86,6 +89,7 @@ char *keywords[] = {
        [Program]  = "program",
        [CreateDev]= "create",
        [Homehost] = "homehost",
+       [HomeCluster] = "homecluster",
        [AutoMode] = "auto",
        [Policy]   = "policy",
        [PartPolicy]="part-policy",
@@ -562,6 +566,21 @@ void homehostline(char *line)
        }
 }
 
+static char *home_cluster = NULL;
+void homeclusterline(char *line)
+{
+       char *w;
+
+       for (w=dl_next(line); w != line ; w=dl_next(w)) {
+               if (home_cluster == NULL) {
+                       if (strcasecmp(w, "<none>")==0)
+                               home_cluster = xstrdup("");
+                       else
+                               home_cluster = xstrdup(w);
+               }
+       }
+}
+
 char auto_yes[] = "yes";
 char auto_no[] = "no";
 char auto_homehost[] = "homehost";
@@ -724,6 +743,9 @@ void conf_file(FILE *f)
                case Homehost:
                        homehostline(line);
                        break;
+               case HomeCluster:
+                       homeclusterline(line);
+                       break;
                case AutoMode:
                        autoline(line);
                        break;
@@ -884,6 +906,12 @@ char *conf_get_homehost(int *require_homehostp)
        return home_host;
 }
 
+char *conf_get_homecluster(void)
+{
+       load_conffile();
+       return home_cluster;
+}
+
 struct createinfo *conf_get_create_info(void)
 {
        load_conffile();