]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
fix load_super/free_super mismatch in util.c
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index 1ba236b781c1ad4dc86563e54edea9133aeffcdb..dbe46404c89ae1d00d649b6ecb02292709e5b879 100644 (file)
--- a/util.c
+++ b/util.c
@@ -818,7 +818,7 @@ struct supertype *guess_super(int fd)
                st->ss = NULL;
                rv = superlist[bestsuper]->load_super(st, fd, NULL);
                if (rv == 0) {
-                       ss->free_super(st);
+                       superlist[bestsuper]->free_super(st);
                        return st;
                }
        }
@@ -830,6 +830,11 @@ struct supertype *guess_super(int fd)
 int get_dev_size(int fd, char *dname, unsigned long long *sizep)
 {
        unsigned long long ldsize;
+       struct stat st;
+
+       if (fstat(fd, &st) != -1 && S_ISREG(st.st_mode))
+               ldsize = (unsigned long long)st.st_size;
+       else
 #ifdef BLKGETSIZE64
        if (ioctl(fd, BLKGETSIZE64, &ldsize) != 0)
 #endif