]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Examine.c
Add must_be_container helper.
[thirdparty/mdadm.git] / Examine.c
index f646805b911dfd66e087a768c81d934959206a8d..ffca9ca5f9d615721b68db3a9af0a1d2eda57788 100644 (file)
--- a/Examine.c
+++ b/Examine.c
@@ -30,7 +30,7 @@
 #endif
 #include       "md_u.h"
 #include       "md_p.h"
-int Examine(mddev_dev_t devlist, int brief, int export, int scan,
+int Examine(struct mddev_dev *devlist, int brief, int export, int scan,
            int SparcAdjust, struct supertype *forcest,
            char *homehost)
 {
@@ -64,6 +64,7 @@ int Examine(mddev_dev_t devlist, int brief, int export, int scan,
 
        for (; devlist ; devlist=devlist->next) {
                struct supertype *st;
+               int have_container = 0;
 
                fd = dev_open(devlist->devname, O_RDONLY);
                if (fd < 0) {
@@ -75,15 +76,29 @@ int Examine(mddev_dev_t devlist, int brief, int export, int scan,
                        err = 1;
                }
                else {
+                       int container = 0;
                        if (forcest)
                                st = dup_super(forcest);
-                       else
+                       else if (must_be_container(fd)) {
+                               /* might be a container */
+                               st = super_by_fd(fd, NULL);
+                               container = 1;
+                       } else
                                st = guess_super(fd);
-                       if (st)
-                               err = st->ss->load_super(st, fd,
-                                                        (brief||scan) ? NULL
-                                                          :devlist->devname);
-                       else {
+                       if (st) {
+                               err = 1;
+                               if (!container)
+                                       err = st->ss->load_super(st, fd,
+                                                                (brief||scan) ? NULL
+                                                                :devlist->devname);
+                               if (err && st->ss->load_container) {
+                                       err = st->ss->load_container(st, fd,
+                                                                (brief||scan) ? NULL
+                                                                :devlist->devname);
+                                       if (!err)
+                                               have_container = 1;
+                               }
+                       } else {
                                if (!brief) {
                                        fprintf(stderr, Name ": No md superblock detected on %s.\n", devlist->devname);
                                        rv = 1;
@@ -122,7 +137,7 @@ int Examine(mddev_dev_t devlist, int brief, int export, int scan,
                                st->ss->getinfo_super(st, &ap->info, NULL);
                        } else
                                st->ss->getinfo_super(st, &ap->info, NULL);
-                       if (!st->loaded_container &&
+                       if (!have_container &&
                            !(ap->info.disk.state & (1<<MD_DISK_SYNC)))
                                ap->spares++;
                        d = dl_strdup(devlist->devname);