]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Examine.c
Add 'supertype' arg to almost all metadata methods.
[thirdparty/mdadm.git] / Examine.c
index 8a8f8f4461aef2b379d64c77d3842b892190986b..b5316b9169149c48d47fb9516925f0dfa67869c8 100644 (file)
--- a/Examine.c
+++ b/Examine.c
@@ -55,7 +55,7 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
         * If (brief) gather devices for same array and just print a mdadm.conf line including devices=
         * if devlist==NULL, use conf_get_devs()
         */
-       int fd; 
+       int fd;
        void *super = NULL;
        int rv = 0;
        int err = 0;
@@ -77,8 +77,9 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
                        if (!scan) {
                                fprintf(stderr,Name ": cannot open %s: %s\n",
                                        devlist->devname, strerror(errno));
-                               err = 1;
+                               rv = 1;
                        }
+                       err = 1;
                }
                else {
                        if (!st)
@@ -86,25 +87,27 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
                        if (st)
                                err = st->ss->load_super(st, fd, &super, (brief||scan)?NULL:devlist->devname);
                        else {
-                               if (!brief)
+                               if (!brief) {
                                        fprintf(stderr, Name ": No md superblock detected on %s.\n", devlist->devname);
+                                       rv = 1;
+                               }
                                err = 1;
                        }
                        close(fd);
                }
-               if (err) {
-                       rv = 1;
+               if (err)
                        continue;
-               }
 
                if (SparcAdjust)
-                       st->ss->update_super(NULL, super, "sparc2.2", devlist->devname, 0, 0, NULL);
+                       st->ss->update_super(st, NULL, super, "sparc2.2",
+                                            devlist->devname, 0, 0, NULL);
                /* Ok, its good enough to try, though the checksum could be wrong */
                if (brief) {
                        struct array *ap;
                        char *d;
                        for (ap=arrays; ap; ap=ap->next) {
-                               if (st->ss == ap->st->ss && st->ss->compare_super(&ap->super, super)==0)
+                               if (st->ss == ap->st->ss &&
+                                   st->ss->compare_super(&ap->super, super)==0)
                                        break;
                        }
                        if (!ap) {
@@ -115,10 +118,10 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
                                ap->spares = 0;
                                ap->st = st;
                                arrays = ap;
-                               st->ss->getinfo_super(&ap->info, super);
+                               st->ss->getinfo_super(st, &ap->info, super);
                        } else {
-                               st->ss->getinfo_super(&ap->info, super);
-                               free(super);
+                               st->ss->getinfo_super(st, &ap->info, super);
+                               st->ss->free_super(st, super);
                        }
                        if (!(ap->info.disk.state & MD_DISK_SYNC))
                                ap->spares++;
@@ -126,8 +129,8 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
                        dl_add(ap->devs, d);
                } else {
                        printf("%s:\n",devlist->devname);
-                       st->ss->examine_super(super, homehost);
-                       free(super);
+                       st->ss->examine_super(st, super, homehost);
+                       st->ss->free_super(st, super);
                }
        }
        if (brief) {
@@ -135,7 +138,7 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
                for (ap=arrays; ap; ap=ap->next) {
                        char sep='=';
                        char *d;
-                       ap->st->ss->brief_examine_super(ap->super);
+                       ap->st->ss->brief_examine_super(ap->st, ap->super);
                        if (ap->spares) printf("   spares=%d", ap->spares);
                        if (brief > 1) {
                                printf("   devices");
@@ -144,7 +147,7 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
                                        sep=',';
                                }
                        }
-                       free(ap->super);
+                       ap->st->ss->free_super(ap->st, ap->super);
                        /* FIXME free ap */
                        if (ap->spares || brief > 1)
                                printf("\n");