]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Be more consistent about keeping the host: prefix on array names.
authorNeilBrown <neilb@suse.de>
Mon, 11 May 2009 05:47:10 +0000 (15:47 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 11 May 2009 05:47:10 +0000 (15:47 +1000)
If an array name contains a "hostname:" prefix, then
--assemble will tend to leave it there, while --incremental
will strip it off (when chosing a device name during auto-assembly).

Make this more consistent:  strip the name off if we decide that
the name will be treated as 'local'.  Leave it on if it will be
treated as 'foreign'.

Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c
Incremental.c

index 2c52f074dd540ea0fbdda9f3cdae35769cd322d6..e75c7e5eaf9c7615f062f6d61bcf20dfa9538772 100644 (file)
@@ -515,6 +515,11 @@ int Assemble(struct supertype *st, char *mddev,
            conf_name_is_free(name))
                trustworthy = LOCAL;
 
+       if (trustworthy == LOCAL &&
+           strchr(name, ':'))
+               /* Ignore 'host:' prefix of name */
+               name = strchr(name, ':')+1;
+
        mdfd = create_mddev(mddev, name, ident->autof, trustworthy,
                            chosen_name);
        if (mdfd < 0) {
index c5ec6340e0efe5c9a4ae865ebee27de1a379eea8..8e711d98910f1d7ffc7faff6c9b858ab3ab9dc37 100644 (file)
@@ -260,12 +260,8 @@ int Incremental(char *devname, int verbose, int runstop,
                return Incremental_container(st, devname, verbose, runstop,
                                             autof, trustworthy);
        }
-       name_to_use = strchr(info.name, ':');
-       if (name_to_use)
-               name_to_use++;
-       else
-               name_to_use = info.name;
 
+       name_to_use = info.name;
        if (name_to_use[0] == 0 &&
            info.array.level == LEVEL_CONTAINER &&
            trustworthy == LOCAL) {
@@ -277,6 +273,12 @@ int Incremental(char *devname, int verbose, int runstop,
            conf_name_is_free(name_to_use))
                trustworthy = LOCAL;
 
+       /* strip "hostname:" prefix from name if we have decided
+        * to treat it as LOCAL
+        */
+       if (trustworthy == LOCAL && strchr(name_to_use, ':') != NULL)
+               name_to_use = strchr(name_to_use, ':')+1;
+
        /* 4/ Check if array exists.
         */
        map_lock(&map);