]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Add guess_super_type
authorNeilBrown <neilb@suse.de>
Thu, 2 Sep 2010 01:54:06 +0000 (11:54 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 6 Sep 2010 01:26:28 +0000 (11:26 +1000)
This can select to only guess array types,
or only guess partition types.

Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.h
util.c

diff --git a/mdadm.h b/mdadm.h
index c513c723c98e5f9f677b8198d04c6630472ef0db..89705603893922c5a8013a23f48f16f67b94540a 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -729,7 +729,11 @@ struct supertype {
 };
 
 extern struct supertype *super_by_fd(int fd);
-extern struct supertype *guess_super(int fd);
+enum guess_types { guess_any, guess_array, guess_partitions };
+extern struct supertype *guess_super_type(int fd, enum guess_types guess_type);
+static inline struct supertype *guess_super(int fd) {
+       return guess_super_type(fd, guess_any);
+}
 extern struct supertype *dup_super(struct supertype *st);
 extern int get_dev_size(int fd, char *dname, unsigned long long *sizep);
 extern void get_one_disk(int mdfd, mdu_array_info_t *ainf,
diff --git a/util.c b/util.c
index c2169d68dfa77d4590c918267f12e194a19fb470..0cb251c31d923d85a6a8fb198b854d9cdc2b6f49 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1087,7 +1087,7 @@ struct supertype *dup_super(struct supertype *orig)
        return st;
 }
 
-struct supertype *guess_super(int fd)
+struct supertype *guess_super_type(int fd, enum guess_types guess_type)
 {
        /* try each load_super to find the best match,
         * and return the best superswitch
@@ -1102,6 +1102,10 @@ struct supertype *guess_super(int fd)
        for (i=0 ; superlist[i]; i++) {
                int rv;
                ss = superlist[i];
+               if (guess_type == guess_array && ss->add_to_super == NULL)
+                       continue;
+               if (guess_type == guess_partitions && ss->add_to_super != NULL)
+                       continue;
                memset(st, 0, sizeof(*st));
                rv = ss->load_super(st, fd, NULL);
                if (rv == 0) {