]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Make sure name matching for array assembly understand the possibility of a homehost
authorNeil Brown <neilb@suse.de>
Tue, 23 May 2006 05:24:22 +0000 (05:24 +0000)
committerNeil Brown <neilb@suse.de>
Tue, 23 May 2006 05:24:22 +0000 (05:24 +0000)
This "--assemble --name=foo" on host 'bar' will assemble an array named
'foo' or 'bar:foo'.

Signed-off-by: Neil Brown <neilb@suse.de>
Assemble.c
mdadm.8

index 1dc0ffc15bf171d313ee4a9e791e2575886aa791..d35aa5a008199d3c34d043a4847b11952b8fa1b7 100644 (file)
 
 #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 ebabaa4f3b9ddbb7544f9d7a53f168ba46c22421..a3d9dc53b0bdb134faeb2ddce7b55f4309087941 100644 (file)
--- 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