]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Assemble: extend --homehost='<ignore>' to allow --name= to ignore homehost
authorNeilBrown <neilb@suse.com>
Fri, 24 Jul 2015 02:50:54 +0000 (12:50 +1000)
committerNeilBrown <neilb@suse.com>
Fri, 24 Jul 2015 02:50:54 +0000 (12:50 +1000)
Also make --homehost='<ignore>' work properly.

Signed-off-by: NeilBrown <neilb@suse.com>
Assemble.c
mdadm.c

index a3d020d0cbc5586a08124b1d9c9e2ca9b7e2c72e..245e2138300e65718b341a65eac83a5eefe70346 100644 (file)
@@ -25,7 +25,7 @@
 #include       "mdadm.h"
 #include       <ctype.h>
 
-static int name_matches(char *found, char *required, char *homehost)
+static int name_matches(char *found, char *required, char *homehost, int require_homehost)
 {
        /* See if the name found matches the required name, possibly
         * prefixed with 'homehost'
@@ -41,6 +41,7 @@ static int name_matches(char *found, char *required, char *homehost)
        l = sep - found;
        if (strncmp(found, "any:", 4) == 0 ||
            (homehost && strcmp(homehost, "any") == 0) ||
+           !require_homehost ||
            (homehost && strlen(homehost) == l &&
             strncmp(found, homehost, l) == 0)) {
                /* matching homehost */
@@ -78,7 +79,7 @@ static int is_member_busy(char *metadata_version)
 static int ident_matches(struct mddev_ident *ident,
                         struct mdinfo *content,
                         struct supertype *tst,
-                        char *homehost,
+                        char *homehost, int require_homehost,
                         char *update, char *devname)
 {
 
@@ -90,7 +91,7 @@ static int ident_matches(struct mddev_ident *ident,
                return 0;
        }
        if (ident->name[0] && (!update || strcmp(update, "name")!= 0) &&
-           name_matches(content->name, ident->name, homehost)==0) {
+           name_matches(content->name, ident->name, homehost, require_homehost)==0) {
                if (devname)
                        pr_err("%s has wrong name.\n", devname);
                return 0;
@@ -330,7 +331,8 @@ static int select_devices(struct mddev_dev *devlist,
                             content = content->next) {
 
                                if (!ident_matches(ident, content, tst,
-                                                  c->homehost, c->update,
+                                                  c->homehost, c->require_homehost,
+                                                  c->update,
                                                   report_mismatch ? devname : NULL))
                                        /* message already printed */;
                                else if (is_member_busy(content->text_version)) {
@@ -372,7 +374,8 @@ static int select_devices(struct mddev_dev *devlist,
                        tst->ss->getinfo_super(tst, content, NULL);
 
                        if (!ident_matches(ident, content, tst,
-                                          c->homehost, c->update,
+                                          c->homehost, c->require_homehost,
+                                          c->update,
                                           report_mismatch ? devname : NULL))
                                goto loop;
 
@@ -396,7 +399,8 @@ static int select_devices(struct mddev_dev *devlist,
                                        goto loop;
                                }
                                if (match && !ident_matches(match, content, tst,
-                                                           c->homehost, c->update,
+                                                           c->homehost, c->require_homehost,
+                                                           c->update,
                                                            report_mismatch ? devname : NULL))
                                        /* Array exists  in mdadm.conf but some
                                         * details don't match, so reject it
diff --git a/mdadm.c b/mdadm.c
index 3dd1bd2c46d08f42dad435cca4e0bc49ba512d7e..93732a8f5aa9918dc908e44129e608b5e2a64cc0 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1247,7 +1247,7 @@ int main(int argc, char *argv[])
                }
        }
 
-       if (c.homehost == NULL)
+       if (c.homehost == NULL && c.require_homehost)
                c.homehost = conf_get_homehost(&c.require_homehost);
        if (c.homehost == NULL || strcasecmp(c.homehost, "<system>")==0) {
                if (gethostname(sys_hostname, sizeof(sys_hostname)) == 0) {