]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Detail.c
introduce --detail-platform to display platform raid capabilities
[thirdparty/mdadm.git] / Detail.c
index 5ff8cd138fd759d6ae2e1ecd1b180d7a7eab1404..0d6bcf5ee7909ce1d1fb31e165076b7553c3c19c 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -530,3 +530,44 @@ out:
        close(fd);
        return rv;
 }
+
+int Detail_Platform(struct superswitch *ss, int scan, int verbose)
+{
+       /* display platform capabilities for the given metadata format
+        * 'scan' in this context means iterate over all metadata types
+        */
+       int i;
+       int err = 1;
+
+       if (ss && ss->detail_platform)
+               err = ss->detail_platform(verbose);
+       else if (ss) {
+               if (verbose)
+                       fprintf(stderr, Name ": %s metadata is platform independent\n",
+                               ss->name ? : "[no name]");
+       } else if (!scan) {
+               if (verbose)
+                       fprintf(stderr, Name ": specify a metadata type or --scan\n");
+       }
+
+       if (!scan)
+               return err;
+
+       for (i = 0; superlist[i]; i++) {
+               struct superswitch *meta = superlist[i];
+
+               if (meta == ss)
+                       continue;
+               if (verbose)
+                       fprintf(stderr, Name ": checking metadata %s\n",
+                               meta->name ? : "[no name]");
+               if (!meta->detail_platform) {
+                       if (verbose)
+                               fprintf(stderr, Name ": %s metadata is platform independent\n",
+                                       meta->name ? : "[no name]");
+               } else
+                       err |= meta->detail_platform(verbose);
+       }
+
+       return err;
+}