From 624920bbb60dafac5719ee42225a3fba9f8464de Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 23 May 2006 05:24:22 +0000 Subject: [PATCH] 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 --- Assemble.c | 22 +++++++++++++++++++++- mdadm.8 | 6 +++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Assemble.c b/Assemble.c index 1dc0ffc1..d35aa5a0 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 ebabaa4f..a3d9dc53 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 -- 2.39.2