summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-11-04 20:50:38 +1100
committerNeilBrown <neilb@suse.de>2008-11-04 20:50:38 +1100
commit1771a6e214755311530a7099374df53d84e06a82 (patch)
treef33736a4858dd4641521cf87d90e4f681fca6400
parentfe056d1fb0b1d08c614f574cceaa640abc382544 (diff)
downloadmdadm-1771a6e214755311530a7099374df53d84e06a82.tar.gz
mdadm-1771a6e214755311530a7099374df53d84e06a82.tar.xz
mdadm-1771a6e214755311530a7099374df53d84e06a82.zip
config: Support container=uuid as alternative to container=/dev/name in mdadm.conf
When mdadm.conf is automatically generated, we might not know a suitable /dev/name. But we do know the uuid of the container. So allow that as an option. Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--Incremental.c32
-rw-r--r--config.c3
-rw-r--r--mdadm.h5
3 files changed, 32 insertions, 8 deletions
diff --git a/Incremental.c b/Incremental.c
index 55a5f10..1cccdf7 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -708,6 +708,31 @@ int IncrementalScan(int verbose)
return rv;
}
+static char *container2devname(char *devname)
+{
+ char *mdname = NULL;
+
+ if (devname[0] == '/') {
+ int fd = open(devname, O_RDONLY);
+ if (fd >= 0) {
+ mdname = devnum2devname(fd2devnum(fd));
+ close(fd);
+ }
+ } else {
+ int uuid[4];
+ struct map_ent *mp, *map = NULL;
+
+ if (!parse_uuid(devname, uuid))
+ return mdname;
+ mp = map_by_uuid(&map, uuid);
+ if (mp)
+ mdname = devnum2devname(mp->devnum);
+ map_free(map);
+ }
+
+ return mdname;
+}
+
int Incremental_container(struct supertype *st, char *devname, int verbose,
int runstop, int autof, int trustworthy)
{
@@ -741,7 +766,6 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
} else
array_list = NULL;
for(; array_list ; array_list = array_list->next) {
- int fd;
char *dn;
if (array_list->member == NULL ||
array_list->container == NULL)
@@ -751,11 +775,9 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
if (array_list->uuid_set &&
!same_uuid(ra->uuid, array_list->uuid, st->ss->swapuuid))
continue;
- fd = open(array_list->container, O_RDONLY);
- if (fd < 0)
+ dn = container2devname(array_list->container);
+ if (dn == NULL)
continue;
- dn = devnum2devname(fd2devnum(fd));
- close(fd);
if (strncmp(dn, ra->text_version+1,
strlen(dn)) != 0 ||
ra->text_version[strlen(dn)+1] != '/') {
diff --git a/config.c b/config.c
index f08a9f0..9eb8197 100644
--- a/config.c
+++ b/config.c
@@ -522,7 +522,8 @@ void arrayline(char *line)
/* subarray within a container */
mis.member = strdup(w+7);
} else if (strncasecmp(w, "container=", 10) == 0) {
- /* the container holding this subarray */
+ /* the container holding this subarray. Either a device name
+ * or a uuid */
mis.container = strdup(w+10);
} else {
fprintf(stderr, Name ": unrecognised word on ARRAY line: %s\n",
diff --git a/mdadm.h b/mdadm.h
index b94cda3..8b82087 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -259,8 +259,9 @@ typedef struct mddev_ident_s {
char *bitmap_file;
int bitmap_fd;
- char *container; /* /dev/whatever name of container. You
- * would expect this to be the 'devname'
+ char *container; /* /dev/whatever name of container, or
+ * uuid of container. You would expect
+ * this to be the 'devname' or UUID
* of some other entry.
*/
char *member; /* subarray within a container */