+ tmpdev->used = 1;
+ }
+
+ if (mdfd < 0) {
+ /* So... it is up to me to open the device.
+ * We create a name '/dev/md/XXX' based on the info in the
+ * superblock, and call open_mddev on that
+ */
+ mdu_array_info_t inf;
+ char *c;
+ if (!first_super) {
+ return 2;
+ }
+ st->ss->getinfo_super(&info, first_super);
+ c = strchr(info.name, ':');
+ if (c) c++; else c= info.name;
+ if (isdigit(*c) && ((ident->autof & 7)==4 || (ident->autof&7)==6))
+ /* /dev/md/d0 style for partitionable */
+ asprintf(&mddev, "/dev/md/d%s", c);
+ else
+ asprintf(&mddev, "/dev/md/%s", c);
+ mdfd = open_mddev(mddev, ident->autof);
+ if (mdfd < 0)
+ return mdfd;
+ vers = md_get_version(mdfd);
+ if (ioctl(mdfd, GET_ARRAY_INFO, &inf)==0) {
+ fprintf(stderr, Name ": %s already active, cannot restart it!\n", mddev);
+ close(mdfd);
+ free(first_super);
+ return 1;
+ }
+ must_close = 1;
+ }
+
+ /* Ok, no bad inconsistancy, we can try updating etc */
+ for (tmpdev = devlist; tmpdev; tmpdev=tmpdev->next) if (tmpdev->used == 1) {
+ char *devname = tmpdev->devname;
+ struct stat stb;