From: Neil Brown Date: Mon, 30 Jan 2006 23:42:53 +0000 (+0000) Subject: Report device size correctly in --detail for Large devices. X-Git-Tag: mdadm-2.3~5 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=commitdiff_plain;h=6ee5c05a11a7c5160178e6eb21a30d294f56f235 Report device size correctly in --detail for Large devices. Signed-off-by: Neil Brown --- diff --git a/Detail.c b/Detail.c index 704fffe1..2986a6eb 100644 --- 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 b3dbca47..abc576ed 100644 --- 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)