diff options
author | Neil Brown <neilb@suse.de> | 2006-05-23 05:24:22 +0000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2006-05-23 05:24:22 +0000 |
commit | 624920bbb60dafac5719ee42225a3fba9f8464de (patch) | |
tree | cef7881b225d4b29bc5e735b040e792f1417083e /Assemble.c | |
parent | 0237e0cafd5ff70304f0b09ed452adbe0e0e6384 (diff) | |
download | mdadm-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>
Diffstat (limited to 'Assemble.c')
-rw-r--r-- | Assemble.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -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); |