From: Dan Williams <dan.j.williams@xxxxxxxxx> Precludes needing to deduce this information later, like in Detail.c and soon in Grow.c. Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> --- Detail.c | 11 ++++------- util.c | 13 ++++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Detail.c b/Detail.c index e0817aa..1f2dbf2 100644 --- a/Detail.c +++ b/Detail.c @@ -97,16 +97,13 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) if (st) max_disks = st->max_devs; - if (sra && is_subarray(sra->text_version) && - strchr(sra->text_version+1, '/')) { + if (st->subarray[0]) { /* This is a subarray of some container. * We want the name of the container, and the member */ - char *s = strchr(sra->text_version+1, '/'); - int dn; - *s++ = '\0'; - member = s; - dn = devname2devnum(sra->text_version+1); + int dn = st->container_dev; + + member = st->subarray; container = map_dev(dev2major(dn), dev2minor(dn), 1); } diff --git a/util.c b/util.c index 5f2694e..5023f42 100644 --- a/util.c +++ b/util.c @@ -1088,6 +1088,7 @@ struct supertype *super_by_fd(int fd) char version[20]; int i; char *subarray = NULL; + int container = NoMdDev; sra = sysfs_read(fd, 0, GET_VERSION); @@ -1109,15 +1110,15 @@ struct supertype *super_by_fd(int fd) } if (minor == -2 && is_subarray(verstr)) { char *dev = verstr+1; + subarray = strchr(dev, '/'); - int devnum; if (subarray) *subarray++ = '\0'; - devnum = devname2devnum(dev); subarray = strdup(subarray); + container = devname2devnum(dev); if (sra) sysfs_free(sra); - sra = sysfs_read(-1, devnum, GET_VERSION); + sra = sysfs_read(-1, container, GET_VERSION); if (sra && sra->text_version[0]) verstr = sra->text_version; else @@ -1132,11 +1133,13 @@ struct supertype *super_by_fd(int fd) if (st) { st->sb = NULL; if (subarray) { - strncpy(st->subarray, subarray, 32); - st->subarray[31] = 0; + strncpy(st->subarray, subarray, sizeof(st->subarray)); + st->subarray[sizeof(st->subarray) - 1] = 0; free(subarray); } else st->subarray[0] = 0; + st->container_dev = container; + st->devnum = fd2devnum(fd); } return st; } -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html