From: Neil Brown Date: Fri, 19 May 2006 07:13:03 +0000 (+0000) Subject: Include homehost information in --detail where appropriate. X-Git-Tag: mdadm-2.5~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6750aa8da57bfc0eb3a3bdc47c289638b1022c8;p=thirdparty%2Fmdadm.git Include homehost information in --detail where appropriate. Signed-off-by: Neil Brown --- diff --git a/Detail.c b/Detail.c index c377f295..832e0d87 100644 --- a/Detail.c +++ b/Detail.c @@ -31,7 +31,7 @@ #include "md_p.h" #include "md_u.h" -int Detail(char *dev, int brief, int test) +int Detail(char *dev, int brief, int test, char *homehost) { /* * Print out details for an md array by using @@ -268,7 +268,7 @@ This is pretty boring } else if (e && e->percent >= 0) printf("\n"); if (super && st) - st->ss->detail_super(super); + st->ss->detail_super(super, homehost); printf(" Number Major Minor RaidDevice State\n"); } diff --git a/mdadm.c b/mdadm.c index d123e49a..de0a503e 100644 --- a/mdadm.c +++ b/mdadm.c @@ -1069,7 +1069,7 @@ int main(int argc, char *argv[]) e->dev); continue; } - rv |= Detail(name, verbose>1?0:verbose+1, test); + rv |= Detail(name, verbose>1?0:verbose+1, test, homehost); put_md_name(name); } } else if (devmode == 'S' && scan) { @@ -1114,7 +1114,7 @@ int main(int argc, char *argv[]) for (dv=devlist ; dv; dv=dv->next) { switch(dv->disposition) { case 'D': - rv |= Detail(dv->devname, brief?1+verbose:0, test); continue; + rv |= Detail(dv->devname, brief?1+verbose:0, test, homehost); continue; case 'K': /* Zero superblock */ rv |= Kill(dv->devname, force, quiet); continue; case 'Q': diff --git a/mdadm.h b/mdadm.h index 7bfd8cb2..2a2529f3 100644 --- a/mdadm.h +++ b/mdadm.h @@ -274,7 +274,7 @@ extern char *map_dev(int major, int minor, int create); extern struct superswitch { void (*examine_super)(void *sbv); void (*brief_examine_super)(void *sbv); - void (*detail_super)(void *sbv); + void (*detail_super)(void *sbv, char *homehost); void (*brief_detail_super)(void *sbv); void (*uuid_from_super)(int uuid[4], void *sbv); void (*getinfo_super)(struct mdinfo *info, void *sbv); @@ -358,7 +358,7 @@ extern int Create(struct supertype *st, char *mddev, int mdfd, int runstop, int verbose, int force, int assume_clean, char *bitmap_file, int bitmap_chunk, int write_behind, int delay); -extern int Detail(char *dev, int brief, int test); +extern int Detail(char *dev, int brief, int test, char *homehost); extern int Query(char *dev); extern int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust, struct supertype *forcest); diff --git a/super0.c b/super0.c index 7fe23366..d1fbfaee 100644 --- a/super0.c +++ b/super0.c @@ -231,7 +231,7 @@ static void brief_examine_super0(void *sbv) printf("\n"); } -static void detail_super0(void *sbv) +static void detail_super0(void *sbv, char *homehost) { mdp_super_t *sb = sbv; printf(" UUID : "); @@ -240,6 +240,13 @@ static void detail_super0(void *sbv) sb->set_uuid2, sb->set_uuid3); else printf("%08x", sb->set_uuid0); + if (homehost) { + unsigned char *hash = SHA1((unsigned char *)homehost, + strlen(homehost), + NULL); + if (memcmp(&sb->set_uuid2, hash, 8)==0) + printf(" (local to host %s)", homehost); + } printf("\n Events : %d.%d\n\n", sb->events_hi, sb->events_lo); } diff --git a/super1.c b/super1.c index a29795a6..77118d42 100644 --- a/super1.c +++ b/super1.c @@ -317,13 +317,18 @@ static void brief_examine_super1(void *sbv) printf("\n"); } -static void detail_super1(void *sbv) +static void detail_super1(void *sbv, char *homehost) { struct mdp_superblock_1 *sb = sbv; int i; - - printf(" Name : %.32s\n", sb->set_name); - printf(" UUID : "); + int l = homehost ? strlen(homehost) : 0; + + printf(" Name : %.32s", sb->set_name); + if (l > 0 && l < 32 && + sb->set_name[l] == ':' && + strncmp(sb->set_name, homehost, l) == 0) + printf(" (local to host %s)", homehost); + printf("\n UUID : "); for (i=0; i<16; i++) { if ((i&3)==0 && i != 0) printf(":"); printf("%02x", sb->set_uuid[i]);