]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Report device size correctly in --detail for Large devices.
authorNeil Brown <neilb@suse.de>
Mon, 30 Jan 2006 23:42:53 +0000 (23:42 +0000)
committerNeil Brown <neilb@suse.de>
Mon, 30 Jan 2006 23:42:53 +0000 (23:42 +0000)
Signed-off-by: Neil Brown <neilb@suse.de>
Detail.c
util.c

index 704fffe14e736b3d9ab2c93cf6412f799cd4615d..2986a6eb818970b13b41e376b652629111b15657 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -166,9 +166,13 @@ int Detail(char *dev, int brief, int test)
                        printf("     Array Size : %llu%s\n", (larray_size>>10), human_size(larray_size));
                if (array.level >= 1) {
                        if (array.major_version != 0 &&
-                           larray_size >= 0xFFFFFFFFULL)
-                               printf("    Device Size : unknown\n");
-                       else
+                           (larray_size >= 0xFFFFFFFFULL|| array.size == 0)) {
+                               unsigned long long dsize = get_component_size(fd);
+                               if (dsize > 0)
+                                       printf("    Device Size : %llu%s\n", dsize, human_size((long long)array.size<<10));
+                               else
+                                       printf("    Device Size : unknown\n");
+                       } else
                                printf("    Device Size : %d%s\n", array.size, human_size((long long)array.size<<10));
                }
                printf("   Raid Devices : %d\n", array.raid_disks);
diff --git a/util.c b/util.c
index b3dbca47f145330585fefc5a155613b2c39e292e..abc576ed3281f07519e97718382e23dfe363caae 100644 (file)
--- a/util.c
+++ b/util.c
@@ -688,10 +688,10 @@ unsigned long long get_component_size(int fd)
        int n;
        if (fstat(fd, &stb)) return 0;
        if (major(stb.st_rdev) == 9)
-               sprintf(fname, "/sys/block/md%d/component_size",
+               sprintf(fname, "/sys/block/md%d/md/component_size",
                        minor(stb.st_rdev));
        else
-               sprintf(fname, "/sys/block/md_d%d/component_size",
+               sprintf(fname, "/sys/block/md_d%d/md/component_size",
                        minor(stb.st_rdev)/16);
        fd = open(fname, O_RDONLY);
        if (fd < 0)