Report uuid in --detail --brief for ddf and intel

The uuid is slightly fictitious but needed for array matching.
This commit is contained in:
NeilBrown 2008-09-18 16:11:40 +10:00
parent d7288ddc3a
commit ff54de6e47
7 changed files with 40 additions and 24 deletions

View File

@ -401,7 +401,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
} }
st->ss->getinfo_super(st, &info); st->ss->getinfo_super(st, &info);
if (uuid_for_name) if (uuid_for_name)
c = fname_from_uuid(st, &info, nbuf); c = fname_from_uuid(st, &info, nbuf, '-');
else { else {
c = strchr(info.name, ':'); c = strchr(info.name, ':');
if (c) c++; else c= info.name; if (c) c++; else c= info.name;

View File

@ -128,7 +128,8 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
continue; continue;
if ((dv=map_dev(disk.major, disk.minor, 1))) { if ((dv=map_dev(disk.major, disk.minor, 1))) {
if ((!st || !st->sb) && if ((!st || !st->sb) &&
(disk.state & (1<<MD_DISK_ACTIVE))) { (array.raid_disks == 0 ||
(disk.state & (1<<MD_DISK_ACTIVE)))) {
/* try to read the superblock from this device /* try to read the superblock from this device
* to get more info * to get more info
*/ */
@ -136,8 +137,9 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
if (fd2 >=0 && st && if (fd2 >=0 && st &&
st->ss->load_super(st, fd2, NULL) == 0) { st->ss->load_super(st, fd2, NULL) == 0) {
st->ss->getinfo_super(st, &info); st->ss->getinfo_super(st, &info);
if (info.array.ctime != array.ctime || if (array.raid_disks != 0 && /* container */
info.array.level != array.level) (info.array.ctime != array.ctime ||
info.array.level != array.level))
st->ss->free_super(st); st->ss->free_super(st);
} }
if (fd2 >= 0) close(fd2); if (fd2 >= 0) close(fd2);

View File

@ -233,7 +233,7 @@ int Incremental(char *devname, int verbose, int runstop,
mp = map_by_uuid(&map, info.uuid); mp = map_by_uuid(&map, info.uuid);
if (uuid_for_name && ! mp) { if (uuid_for_name && ! mp) {
name_to_use = fname_from_uuid(st, &info, nbuf); name_to_use = fname_from_uuid(st, &info, nbuf, '-');
if (verbose >= 0) if (verbose >= 0)
fprintf(stderr, Name fprintf(stderr, Name
": not found in mdadm.conf and not identified by homehost" ": not found in mdadm.conf and not identified by homehost"
@ -804,7 +804,7 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
! *name_to_use || ! *name_to_use ||
(*devname != '/' || strncmp("UUID-", strrchr(devname,'/')+1,5) == 0) (*devname != '/' || strncmp("UUID-", strrchr(devname,'/')+1,5) == 0)
) )
name_to_use = fname_from_uuid(st, ra, nbuf); name_to_use = fname_from_uuid(st, ra, nbuf, '-');
if (mp) if (mp)
devnum = mp->devnum; devnum = mp->devnum;

View File

@ -764,7 +764,7 @@ extern void uuid_from_super(int uuid[4], mdp_super_t *super);
extern int same_uuid(int a[4], int b[4], int swapuuid); extern int same_uuid(int a[4], int b[4], int swapuuid);
extern void copy_uuid(void *a, int b[4], int swapuuid); extern void copy_uuid(void *a, int b[4], int swapuuid);
extern char *fname_from_uuid(struct supertype *st, extern char *fname_from_uuid(struct supertype *st,
struct mdinfo *info, char *buf); struct mdinfo *info, char *buf, char sep);
extern unsigned long calc_csum(void *super, int bytes); extern unsigned long calc_csum(void *super, int bytes);
extern int enough(int level, int raid_disks, int layout, int clean, extern int enough(int level, int raid_disks, int layout, int clean,
char *avail, int avail_disks); char *avail, int avail_disks);

View File

@ -1100,20 +1100,18 @@ static void examine_super_ddf(struct supertype *st, char *homehost)
examine_pds(sb); examine_pds(sb);
} }
static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info);
static void brief_examine_super_ddf(struct supertype *st) static void brief_examine_super_ddf(struct supertype *st)
{ {
/* We just write a generic DDF ARRAY entry /* We just write a generic DDF ARRAY entry
* The uuid is all hex, 6 groups of 4 bytes
*/ */
struct ddf_super *ddf = st->sb; struct mdinfo info;
int i; char nbuf[64];
printf("ARRAY /dev/ddf metadata=ddf UUID="); getinfo_super_ddf(st, &info);
for (i = 0; i < DDF_GUID_LEN; i++) { fname_from_uuid(st, &info, nbuf, ':');
if ((i&3) == 0 && i != 0) printf("ARRAY /dev/ddf metadata=ddf UUID=%s\n", nbuf + 5);
printf(":");
printf("%02X", 255&ddf->anchor.guid[i]);
}
printf("\n");
} }
static void detail_super_ddf(struct supertype *st, char *homehost) static void detail_super_ddf(struct supertype *st, char *homehost)
@ -1132,6 +1130,11 @@ static void brief_detail_super_ddf(struct supertype *st)
* Can that be stored in ddf_super?? * Can that be stored in ddf_super??
*/ */
// struct ddf_super *ddf = st->sb; // struct ddf_super *ddf = st->sb;
struct mdinfo info;
char nbuf[64];
getinfo_super_ddf(st, &info);
fname_from_uuid(st, &info, nbuf,':');
printf(" UUID=%s", nbuf + 5);
} }
#endif #endif

View File

@ -560,9 +560,18 @@ static void examine_super_imsm(struct supertype *st, char *homehost)
} }
} }
static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info);
static void brief_examine_super_imsm(struct supertype *st) static void brief_examine_super_imsm(struct supertype *st)
{ {
printf("ARRAY /dev/imsm metadata=imsm\n"); /* We just write a generic DDF ARRAY entry
*/
struct mdinfo info;
char nbuf[64];
getinfo_super_imsm(st, &info);
fname_from_uuid(st, &info, nbuf,'-');
printf("ARRAY /dev/imsm metadata=imsm UUID=%s\n", nbuf + 5);
} }
static void detail_super_imsm(struct supertype *st, char *homehost) static void detail_super_imsm(struct supertype *st, char *homehost)
@ -572,7 +581,11 @@ static void detail_super_imsm(struct supertype *st, char *homehost)
static void brief_detail_super_imsm(struct supertype *st) static void brief_detail_super_imsm(struct supertype *st)
{ {
printf("%s\n", __FUNCTION__); struct mdinfo info;
char nbuf[64];
getinfo_super_imsm(st, &info);
fname_from_uuid(st, &info, nbuf,'-');
printf(" UUID=%s", nbuf + 5);
} }
#endif #endif

8
util.c
View File

@ -269,7 +269,7 @@ void copy_uuid(void *a, int b[4], int swapuuid)
memcpy(a, b, 16); memcpy(a, b, 16);
} }
char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf) char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf, char sep)
{ {
int i; int i;
char uuid[16]; char uuid[16];
@ -278,10 +278,8 @@ char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf)
c += strlen(c); c += strlen(c);
copy_uuid(uuid, info->uuid, st->ss->swapuuid); copy_uuid(uuid, info->uuid, st->ss->swapuuid);
for (i=0; i<16; i++) { for (i=0; i<16; i++) {
if (i && (i&3)==0) { if (i && (i&3)==0)
strcpy(c, "-"); *c++ = sep;
c++;
}
sprintf(c,"%02x", (unsigned char)uuid[i]); sprintf(c,"%02x", (unsigned char)uuid[i]);
c+= 2; c+= 2;
} }