Include homehost information in --examine as appropriate

Signed-off-by: Neil Brown <neilb@suse.de>
This commit is contained in:
Neil Brown 2006-05-19 07:19:04 +00:00
parent b6750aa8da
commit a1cbd7d053
5 changed files with 27 additions and 12 deletions

View File

@ -35,7 +35,9 @@
#endif
#include "md_u.h"
#include "md_p.h"
int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust, struct supertype *forcest)
int Examine(mddev_dev_t devlist, int brief, int scan,
int SparcAdjust, struct supertype *forcest,
char *homehost)
{
/* Read the raid superblock from a device and
@ -124,7 +126,7 @@ int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust, struct su
dl_add(ap->devs, d);
} else {
printf("%s:\n",devlist->devname);
st->ss->examine_super(super);
st->ss->examine_super(super, homehost);
free(super);
}
}

View File

@ -1054,7 +1054,7 @@ int main(int argc, char *argv[])
fprintf(stderr, Name ": No devices listed in %s\n", configfile?configfile:DefaultConfFile);
exit(1);
}
rv = Examine(devlist, scan?(verbose>1?0:verbose+1):brief, scan, SparcAdjust, ss);
rv = Examine(devlist, scan?(verbose>1?0:verbose+1):brief, scan, SparcAdjust, ss, homehost);
} else {
if (devlist == NULL) {
if (devmode=='D' && scan) {

View File

@ -272,7 +272,7 @@ extern char *map_dev(int major, int minor, int create);
extern struct superswitch {
void (*examine_super)(void *sbv);
void (*examine_super)(void *sbv, char *homehost);
void (*brief_examine_super)(void *sbv);
void (*detail_super)(void *sbv, char *homehost);
void (*brief_detail_super)(void *sbv);
@ -361,7 +361,7 @@ extern int Create(struct supertype *st, char *mddev, int mdfd,
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);
struct supertype *forcest, char *homehost);
extern int Monitor(mddev_dev_t devlist,
char *mailaddr, char *alert_cmd,
int period, int daemonise, int scan, int oneshot,

View File

@ -84,7 +84,7 @@ void super0_swap_endian(struct mdp_superblock_s *sb)
#ifndef MDASSEMBLE
static void examine_super0(void *sbv)
static void examine_super0(void *sbv, char *homehost)
{
mdp_super_t *sb = sbv;
time_t atime;
@ -94,10 +94,18 @@ static void examine_super0(void *sbv)
printf(" Magic : %08x\n", sb->md_magic);
printf(" Version : %02d.%02d.%02d\n", sb->major_version, sb->minor_version,
sb->patch_version);
if (sb->minor_version >= 90)
printf(" UUID : %08x:%08x:%08x:%08x\n", sb->set_uuid0, sb->set_uuid1,
if (sb->minor_version >= 90) {
printf(" UUID : %08x:%08x:%08x:%08x", sb->set_uuid0, sb->set_uuid1,
sb->set_uuid2, sb->set_uuid3);
else
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");
} else
printf(" UUID : %08x\n", sb->set_uuid0);
atime = sb->ctime;

View File

@ -136,7 +136,7 @@ static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb)
}
#ifndef MDASSEMBLE
static void examine_super1(void *sbv)
static void examine_super1(void *sbv, char *homehost)
{
struct mdp_superblock_1 *sb = sbv;
time_t atime;
@ -144,6 +144,7 @@ static void examine_super1(void *sbv)
int faulty;
int i;
char *c;
int l = homehost ? strlen(homehost) : 0;
printf(" Magic : %08x\n", __le32_to_cpu(sb->magic));
printf(" Version : %02d\n", 1);
@ -154,8 +155,12 @@ static void examine_super1(void *sbv)
printf("%02x", sb->set_uuid[i]);
}
printf("\n");
printf(" Name : %.32s\n", sb->set_name);
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");
atime = __le64_to_cpu(sb->ctime) & 0xFFFFFFFFFFULL;
printf(" Creation Time : %.24s\n", ctime(&atime));
c=map_num(pers, __le32_to_cpu(sb->level));