]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Query.c
Add 'supertype' arg to almost all metadata methods.
[thirdparty/mdadm.git] / Query.c
diff --git a/Query.c b/Query.c
index 4cae45085469d6331d4b21849bf6c7bbfca36002..19b2ce5e621c226445003cb5ec631b6b0371142b 100644 (file)
--- a/Query.c
+++ b/Query.c
@@ -34,7 +34,7 @@
 int Query(char *dev)
 {
        /* Give a brief description of the device,
-        * whether it is an md device and whether it has 
+        * whether it is an md device and whether it has
         * a superblock
         */
        int fd = open(dev, O_RDONLY, 0);
@@ -47,7 +47,6 @@ int Query(char *dev)
        struct supertype *st = NULL;
 
        unsigned long long larray_size;
-       unsigned long array_size;
        struct stat stb;
        char *mddev;
        mdu_disk_info_t disc;
@@ -63,22 +62,15 @@ int Query(char *dev)
        if (ioctl(fd, GET_ARRAY_INFO, &array)<0)
                ioctlerr = errno;
        else ioctlerr = 0;
+
        fstat(fd, &stb);
 
        if (vers>=9000 && !ioctlerr) {
-#ifdef BLKGETSIZE64
-               if (ioctl(fd, BLKGETSIZE64, &larray_size)==0)
-                       ;
-               else
-#endif
-                       if (ioctl(fd, BLKGETSIZE, &array_size)==0) {
-                               larray_size = array_size;
-                               larray_size <<= 9;
-                       } else larray_size = 0;
+               if (!get_dev_size(fd, NULL, &larray_size))
+                       larray_size = 0;
        }
 
-       if (vers < 0) 
+       if (vers < 0)
                printf("%s: is not an md array\n", dev);
        else if (vers < 9000)
                printf("%s: is an md device, but kernel cannot provide details\n", dev);
@@ -99,18 +91,18 @@ int Query(char *dev)
        if (st) {
                superror = st->ss->load_super(st, fd, &super, dev);
                superrno = errno;
-       } else 
+       } else
                superror = -1;
        close(fd);
        if (superror == 0) {
                /* array might be active... */
-               st->ss->getinfo_super(&info, super);
+               st->ss->getinfo_super(st, &info, super);
                if (st->ss->major == 0) {
                        mddev = get_md_name(info.array.md_minor);
                        disc.number = info.disk.number;
                        activity = "undetected";
                        if (mddev && (fd = open(mddev, O_RDONLY))>=0) {
-                               if (md_get_version(fd) >= 9000 &&       
+                               if (md_get_version(fd) >= 9000 &&
                                    ioctl(fd, GET_ARRAY_INFO, &array)>= 0) {
                                        if (ioctl(fd, GET_DISK_INFO, &disc) >= 0 &&
                                            makedev((unsigned)disc.major,(unsigned)disc.minor) == stb.st_rdev)
@@ -125,13 +117,14 @@ int Query(char *dev)
                        mddev = "array";
                }
                printf("%s: device %d in %d device %s %s %s.  Use mdadm --examine for more detail.\n",
-                      dev, 
+                      dev,
                       info.disk.number, info.array.raid_disks,
                       activity,
                       map_num(pers, info.array.level),
                       mddev);
+               if (st->ss->major == 0)
+                       put_md_name(mddev);
        }
        return 0;
 }
 
-