summaryrefslogtreecommitdiff
path: root/mapfile.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2014-11-03 12:49:05 +1100
committerNeilBrown <neilb@suse.de>2014-11-03 12:49:05 +1100
commit628cdf19ea35daad22e409e51c0abc7ffb19d6aa (patch)
treea4313890310a3ba7dc94219bb34cc1fafc421c23 /mapfile.c
parent36dab45b89a65dc2eb4a0a5efda08f6c5d2e8856 (diff)
downloadmdadm-628cdf19ea35daad22e409e51c0abc7ffb19d6aa.tar.gz
Rebuildmap: strip local host name from device name.
When /run/mdadm/map is being rebuilt, e.g. by "mdadm -Ir", if the device doesn't exist in /dev, we have to choose a name. Currently we don't strip the hostname which is wrong if it is the local host. Reported-by: Stephen Kent <smkent@smkent.net> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mapfile.c')
-rw-r--r--mapfile.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/mapfile.c b/mapfile.c
index 4e7f242..41599df 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -455,12 +455,19 @@ void RebuildMap(void)
sep = "";
}
}
- if (strchr(name, ':'))
- /* probably a uniquifying
+ if (strchr(name, ':')) {
+ /* Probably a uniquifying
* hostname prefix. Allow
- * without a suffix
+ * without a suffix, and strip
+ * hostname if it is us.
*/
+ if (homehost && unum == -1 &&
+ strncmp(name, homehost,
+ strlen(homehost)) == 0 &&
+ name[strlen(homehost)] == ':')
+ name += strlen(homehost)+1;
unum = -1;
+ }
while (conflict) {
if (unum >= 0)