summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-11-22 09:35:25 +0100
committerNeilBrown <neilb@suse.de>2010-11-22 09:35:25 +0100
commitca145a1e4c9ec2c95f95f6283a3ce290f3d4da0d (patch)
treedb8bd6ed83c2ebbebeb65d89acdd5cd233dde032
parentsuper_by_fd: return subarray info explicitly. (diff)
downloadmdadm-ca145a1e4c9ec2c95f95f6283a3ce290f3d4da0d.tar.xz
mdadm-ca145a1e4c9ec2c95f95f6283a3ce290f3d4da0d.zip
mapinfo: simplify subarray handling.
We don't need ->container_dev here, and we will soon be passing subarray as an explicit arg to load_super. So simplify extraction of subarray and move the strcpy close to ->load_super. Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--mapfile.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/mapfile.c b/mapfile.c
index b22772c4..2645aa95 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -334,31 +334,20 @@ struct map_ent *map_by_name(struct map_ent **map, char *name)
* version super_by_fd does this automatically, this routine is meant as
* a supplement for guess_super()
*/
-static void set_member_info(struct supertype *st, struct mdstat_ent *ent)
+static char *get_member_info(struct mdstat_ent *ent)
{
- st->subarray[0] = '\0';
-
if (ent->metadata_version == NULL ||
strncmp(ent->metadata_version, "external:", 9) != 0)
- return;
+ return NULL;
if (is_subarray(&ent->metadata_version[9])) {
- char version[strlen(ent->metadata_version)+1];
char *subarray;
- char *name = &version[10];
-
- strcpy(version, ent->metadata_version);
- subarray = strrchr(version, '/');
- name = &version[10];
- if (!subarray)
- return;
- *subarray++ = '\0';
-
- st->container_dev = devname2devnum(name);
- strncpy(st->subarray, subarray, sizeof(st->subarray));
+ subarray = strrchr(ent->metadata_version, '/');
+ return subarray + 1;
}
+ return NULL;
}
void RebuildMap(void)
@@ -402,7 +391,8 @@ void RebuildMap(void)
if ( st == NULL)
ok = -1;
else {
- set_member_info(st, md);
+ char *subarray = get_member_info(md);
+ strcpy(st->subarray, subarray);
ok = st->ss->load_super(st, dfd, NULL);
}
close(dfd);