summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-23 05:24:22 +0000
committerNeil Brown <neilb@suse.de>2006-05-23 05:24:22 +0000
commit624920bbb60dafac5719ee42225a3fba9f8464de (patch)
treecef7881b225d4b29bc5e735b040e792f1417083e
parent0237e0cafd5ff70304f0b09ed452adbe0e0e6384 (diff)
downloadmdadm-624920bbb60dafac5719ee42225a3fba9f8464de.tar.gz
mdadm-624920bbb60dafac5719ee42225a3fba9f8464de.tar.xz
mdadm-624920bbb60dafac5719ee42225a3fba9f8464de.zip
Make sure name matching for array assembly understand the possibility of a homehost
This "--assemble --name=foo" on host 'bar' will assemble an array named 'foo' or 'bar:foo'. Signed-off-by: Neil Brown <neilb@suse.de>
-rw-r--r--Assemble.c22
-rw-r--r--mdadm.86
2 files changed, 26 insertions, 2 deletions
diff --git a/Assemble.c b/Assemble.c
index 1dc0ffc..d35aa5a 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -29,6 +29,26 @@
#include "mdadm.h"
+static int name_matches(char *found, char *required, char *homehost)
+{
+ /* See if the name found matches the required name, possibly
+ * prefixed with 'homehost'
+ */
+ char fnd[33];
+
+ strncpy(fnd, found, 32);
+ fnd[32] = 0;
+ if (strcmp(found, required)==0)
+ return 1;
+ if (homehost) {
+ int l = strlen(homehost);
+ if (l < 32 && fnd[l] == ':' &&
+ strcmp(fnd+l+1, required)==0)
+ return 1;
+ }
+ return 0;
+}
+
int Assemble(struct supertype *st, char *mddev, int mdfd,
mddev_ident_t ident, char *conffile,
mddev_dev_t devlist, char *backup_file,
@@ -226,7 +246,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
continue;
}
if (ident->name[0] && (!update || strcmp(update, "name")!= 0) &&
- (!super || strncmp(info.name, ident->name, 32)!=0)) {
+ (!super || name_matches(info.name, ident->name, homehost)==0)) {
if ((inargv && verbose >= 0) || verbose > 0)
fprintf(stderr, Name ": %s has wrong name.\n",
devname);
diff --git a/mdadm.8 b/mdadm.8
index ebabaa4..a3d9dc5 100644
--- a/mdadm.8
+++ b/mdadm.8
@@ -595,7 +595,11 @@ will look for super blocks with a minor number of 0.
.TP
.BR -N ", " --name=
Specify the name of the array to assemble. This must be the name
-that was specified when creating the array.
+that was specified when creating the array. It must either match
+then name stored in the superblock exactly, or it must match
+which the current
+.I homehost
+is added to the start of the given name.
.TP
.BR -f ", " --force