From cd29a5c835c11cbcedc10487677eac6a946ad61b Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 6 Mar 2002 23:17:40 +0000 Subject: mdctl-0.6 --- Detail.c | 147 +++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 82 insertions(+), 65 deletions(-) (limited to 'Detail.c') diff --git a/Detail.c b/Detail.c index 026c3b3..7c2860d 100644 --- a/Detail.c +++ b/Detail.c @@ -1,7 +1,7 @@ /* * mdctl - manage Linux "md" devices aka RAID arrays. * - * Copyright (C) 2001 Neil Brown + * Copyright (C) 2001-2002 Neil Brown * * * This program is free software; you can redistribute it and/or modify @@ -31,7 +31,7 @@ #include "md_p.h" #include "md_u.h" -int Detail(char *dev) +int Detail(char *dev, int brief) { /* * Print out details for an md array by using @@ -77,48 +77,59 @@ int Detail(char *dev) return 1; } /* Ok, we have some info to print... */ - printf("%s:\n", dev); - printf(" Version : %02d.%02d.%02d\n", - array.major_version, array.minor_version, array.patch_version); - atime = array.ctime; - printf(" Creation Time : %.24s\n", ctime(&atime)); c = map_num(pers, array.level); - printf(" Raid Level : %s\n", c?c:"-unknown-"); - printf(" Size : %d\n", array.size); - printf(" Raid Disks : %d\n", array.raid_disks); - printf(" Total Disks : %d\n", array.nr_disks); - printf("Preferred Minor : %d\n", array.md_minor); - printf(" Persistance : Superblock is %spersistant\n", - array.not_persistent?"not ":""); - printf("\n"); - atime = array.utime; - printf(" Update Time : %.24s\n", ctime(&atime)); - printf(" State : %s, %serrors\n", - (array.state&(1<>= 1; + printf("%s:\n", dev); + printf(" Version : %02d.%02d.%02d\n", + array.major_version, array.minor_version, array.patch_version); + atime = array.ctime; + printf(" Creation Time : %.24s\n", ctime(&atime)); + printf(" Raid Level : %s\n", c?c:"-unknown-"); + if (array_size) + printf(" Array Size : %d%s\n", array_size, human_size(array_size)); + if (array.level >= 1) + printf(" Device Size : %d%s\n", array.size, human_size(array.size)); + printf(" Raid Disks : %d\n", array.raid_disks); + printf(" Total Disks : %d\n", array.nr_disks); + printf("Preferred Minor : %d\n", array.md_minor); + printf(" Persistance : Superblock is %spersistant\n", + array.not_persistent?"not ":""); + printf("\n"); + atime = array.utime; + printf(" Update Time : %.24s\n", ctime(&atime)); + printf(" State : %s, %serrors\n", + (array.state&(1<=0 && - load_super(fd, &super) ==0 && - super.ctime == array.ctime && - super.level == array.level) - have_super = 1; - } + if (!brief) printf(" %s", dv); + if (!have_super) { + /* try to read the superblock from this device + * to get more info + */ + int fd = open(dv, O_RDONLY); + if (fd >=0 && + load_super(fd, &super) ==0 && + super.ctime == array.ctime && + super.level == array.level) + have_super = 1; + } } - printf("\n"); + if (!brief) printf("\n"); } if (have_super) { + if (brief) printf(" UUID="); + else printf(" UUID : "); if (super.minor_version >= 90) - printf(" UUID : %08x:%08x:%08x:%08x\n", super.set_uuid0, super.set_uuid1, - super.set_uuid2, super.set_uuid3); - else - printf(" UUID : %08x\n", super.set_uuid0); + printf("%08x:%08x:%08x:%08x", super.set_uuid0, super.set_uuid1, + super.set_uuid2, super.set_uuid3); + else + printf("%08x", super.set_uuid0); + if (!brief) printf("\n"); } + if (brief) printf("\n"); return 0; } -- cgit