mdadm: force a uuid swap on big endian

The code path for metadata 0.90 calls a common routine
fname_from_uuid that uses metadata 1.2. The code expects member
swapuuid to be setup and usable. But it is only setup when using
metadata 1.2. Since the metadata 0.90 did not create swapuuid
and set it. The test (st->ss == &super1) ? 1 : st->ss->swapuuid
fails. The swapuuid is set at compile time based on byte order.
Any call based on metadata 0.90 and on big endian processors,
the --export uuid will be incorrect.

Signed-Off-by: Nigel Croxon <ncroxon@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
This commit is contained in:
Nigel Croxon 2019-09-24 11:39:24 -04:00 committed by Jes Sorensen
parent 43ebc9105e
commit 2c2d9c48d2
1 changed files with 4 additions and 0 deletions

4
util.c
View File

@ -685,8 +685,12 @@ char *fname_from_uuid(struct supertype *st, struct mdinfo *info,
// work, but can't have it set if we want this printout to match
// all the other uuid printouts in super1.c, so we force swapuuid
// to 1 to make our printout match the rest of super1
#if __BYTE_ORDER == BIG_ENDIAN
return __fname_from_uuid(info->uuid, 1, buf, sep);
#else
return __fname_from_uuid(info->uuid, (st->ss == &super1) ? 1 :
st->ss->swapuuid, buf, sep);
#endif
}
int check_ext2(int fd, char *name)