diff --git a/Create.c b/Create.c index bbf2f2b..337040c 100644 --- a/Create.c +++ b/Create.c @@ -672,7 +672,7 @@ int Create(struct supertype *st, char *mddev, sysfs_init(&info, mdfd, 0); - if (st->ss->external && st->subarray[0]) { + if (st->ss->external && st->container_dev != NoMdDev) { /* member */ /* When creating a member, we need to be careful @@ -775,7 +775,8 @@ int Create(struct supertype *st, char *mddev, if (have_container) fd = -1; else { - if (st->ss->external && st->subarray[0]) + if (st->ss->external && + st->container_dev != NoMdDev) fd = open(dv->devname, O_RDWR); else fd = open(dv->devname, O_RDWR|O_EXCL); @@ -906,7 +907,7 @@ int Create(struct supertype *st, char *mddev, } if (verbose >= 0) fprintf(stderr, Name ": array %s started.\n", mddev); - if (st->ss->external && st->subarray[0]) { + if (st->ss->external && st->container_dev != NoMdDev) { if (need_mdmon) start_mdmon(st->container_dev); diff --git a/super-ddf.c b/super-ddf.c index ab35891..01c376d 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -893,6 +893,7 @@ static struct supertype *match_metadata_desc_ddf(char *arg) st = malloc(sizeof(*st)); memset(st, 0, sizeof(*st)); + st->container_dev = NoMdDev; st->ss = &super_ddf; st->max_devs = 512; st->minor_version = 0; diff --git a/super-intel.c b/super-intel.c index 3c18e57..5470c91 100644 --- a/super-intel.c +++ b/super-intel.c @@ -333,6 +333,7 @@ static struct supertype *match_metadata_desc_imsm(char *arg) if (!st) return NULL; memset(st, 0, sizeof(*st)); + st->container_dev = NoMdDev; st->ss = &super_imsm; st->max_devs = IMSM_MAX_DEVICES; st->minor_version = 0; diff --git a/super0.c b/super0.c index 74b05ae..1fcdd24 100644 --- a/super0.c +++ b/super0.c @@ -917,6 +917,7 @@ static struct supertype *match_metadata_desc0(char *arg) if (!st) return st; memset(st, 0, sizeof(*st)); + st->container_dev = NoMdDev; st->ss = &super0; st->info = NULL; st->minor_version = 90; diff --git a/super1.c b/super1.c index ca2a54e..6974daa 100644 --- a/super1.c +++ b/super1.c @@ -1371,6 +1371,7 @@ static struct supertype *match_metadata_desc1(char *arg) if (!st) return st; memset(st, 0, sizeof(*st)); + st->container_dev = NoMdDev; st->ss = &super1; st->max_devs = 384; st->sb = NULL; diff --git a/util.c b/util.c index 83a972e..57b7e1f 100644 --- a/util.c +++ b/util.c @@ -1126,6 +1126,9 @@ struct supertype *guess_super_type(int fd, enum guess_types guess_type) int i; st = malloc(sizeof(*st)); + memset(st, 0, sizeof(*st)); + st->container_dev = NoMdDev; + for (i=0 ; superlist[i]; i++) { int rv; ss = superlist[i];