From: Doug Ledford Date: Wed, 29 Oct 2008 19:05:35 +0000 (-0400) Subject: Fix bad metadata formatting X-Git-Tag: mdadm-3.0-devel2~61^2~4 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=commitdiff_plain;h=d7ee65c960fa8a6886df7416307f57545ddc4460 Fix bad metadata formatting Certain operations (Detail.c mainly) would print out the metadata of an array in a format that the scan operation in super0.c and super1.c would later reject as unknown when it was found in the mdadm.conf file. Use a consistent format, but also modify the super0 and super1 match methods to accept the other format without complaint. Signed-off-by: Doug Ledford Signed-off-by: NeilBrown --- diff --git a/Detail.c b/Detail.c index 25b91b1e..9ba8af1d 100644 --- a/Detail.c +++ b/Detail.c @@ -138,7 +138,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) if (sra && sra->array.major_version < 0) printf("MD_METADATA=%s\n", sra->text_version); else - printf("MD_METADATA=%02d.%02d\n", + printf("MD_METADATA=%d.%02d\n", array.major_version, array.minor_version); if (st && st->sb) @@ -154,7 +154,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) if (sra && sra->array.major_version < 0) printf(" metadata=%s", sra->text_version); else - printf(" metadata=%02d.%02d", + printf(" metadata=%d.%02d", array.major_version, array.minor_version); /* Only try GET_BITMAP_FILE for 0.90.01 and later */ @@ -183,7 +183,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) if (sra && sra->array.major_version < 0) printf(" Version : %s\n", sra->text_version); else - printf(" Version : %02d.%02d\n", + printf(" Version : %d.%02d\n", array.major_version, array.minor_version); atime = array.ctime; diff --git a/super0.c b/super0.c index 71dc39ce..90fdf23d 100644 --- a/super0.c +++ b/super0.c @@ -93,7 +93,7 @@ static void examine_super0(struct supertype *st, char *homehost) char *c; printf(" Magic : %08x\n", sb->md_magic); - printf(" Version : %02d.%02d.%02d\n", sb->major_version, sb->minor_version, + printf(" Version : %d.%02d.%02d\n", sb->major_version, sb->minor_version, sb->patch_version); if (sb->minor_version >= 90) { printf(" UUID : %08x:%08x:%08x:%08x", sb->set_uuid0, sb->set_uuid1, @@ -846,6 +846,9 @@ static struct supertype *match_metadata_desc0(char *arg) st->minor_version = 90; st->max_devs = MD_SB_DISKS; st->sb = NULL; + /* Eliminate pointless leading 0 from some versions of mdadm -D */ + if (strncmp(arg, "00.", 3) == 0) + arg++; if (strcmp(arg, "0") == 0 || strcmp(arg, "0.90") == 0 || strcmp(arg, "default") == 0 || diff --git a/super1.c b/super1.c index 62a3ab9e..1eb88aac 100644 --- a/super1.c +++ b/super1.c @@ -1203,6 +1203,9 @@ static struct supertype *match_metadata_desc1(char *arg) st->ss = &super1; st->max_devs = 384; st->sb = NULL; + /* Eliminate pointless leading 0 from some versions of mdadm -D */ + if (strncmp(arg, "01.", 3) == 0) + arg++; if (strcmp(arg, "1.0") == 0) { st->minor_version = 0; return st;