]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
Remember to close directories when we are finished with them.
[thirdparty/mdadm.git] / Assemble.c
index 16dec24678e03abe057dafe6079d9a3d9d4ceee8..9c320c2d8aea7ceffb680b5b03a90e41b782b539 100644 (file)
@@ -481,7 +481,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                } else
 #endif
                {
-                       struct supertype *tst = dup_super(st);;
+                       struct supertype *tst = dup_super(st);
                        int dfd;
                        dfd = dev_open(devname, O_RDWR|O_EXCL);
 
@@ -913,15 +913,12 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                        if (j >= 0 /* && devices[j].uptodate */) {
 #ifndef MDASSEMBLE
                                if (st->ss->external) {
-                                       int fd = dev_open(devices[j].devname,
-                                                         O_RDONLY);
-                                       if (fd < 0)
-                                               rv = 1;
-                                       else {
-                                               rv = sysfs_add_disk(sra, fd,
-                                                             &devices[j].i);
-                                               close(fd);
-                                       }
+                                       devices[j].i.disk.number =
+                                               devices[j].i.disk.raid_disk;
+                                       st->ss->getinfo_super_n(st,
+                                                               &devices[j].i);
+                                       rv = sysfs_add_disk(sra,
+                                                           &devices[j].i);
                                } else
 #endif
                                        rv = ioctl(mdfd, ADD_NEW_DISK,
@@ -948,6 +945,21 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                                        i, mddev);
                }
 
+               if (info.array.level == LEVEL_CONTAINER) {
+                       if (verbose >= 0) {
+                               fprintf(stderr, Name ": Container %s has been "
+                                       "assembled with %d drive%s",
+                                       mddev, okcnt, okcnt==1?"":"s");
+                               if (okcnt < info.array.raid_disks)
+                                       fprintf(stderr, " (out of %d)",
+                                               info.array.raid_disks);
+                               fprintf(stderr, "\n");
+                       }
+                       if (must_close)
+                               close(mdfd);
+                       return 0;
+               }
+
                if (runstop == 1 ||
                    (runstop <= 0 &&
                     ( enough(info.array.level, info.array.raid_disks,
@@ -970,7 +982,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                                        /* There is a nasty race with 'mdadm --monitor'.
                                         * If it opens this device before we close it,
                                         * it gets an incomplete open on which IO
-                                        * doesn't work and the capacity if wrong.
+                                        * doesn't work and the capacity is
+                                        * wrong.
                                         * If we reopen (to check for layered devices)
                                         * before --monitor closes, we loose.
                                         *