]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix bad metadata formatting
authorDoug Ledford <dledford@redhat.com>
Wed, 29 Oct 2008 19:05:35 +0000 (15:05 -0400)
committerNeilBrown <neilb@suse.de>
Wed, 29 Oct 2008 21:53:02 +0000 (08:53 +1100)
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 <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Detail.c
super0.c
super1.c

index 25b91b1e256b5cdf94fe9ff3d69a052de024f6cb..9ba8af1d4da2cae97a30f80a4a4a8b27030f4642 100644 (file)
--- 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;
index 71dc39ce4a0dec2ccbb18c0d67ad19e09d636fca..90fdf23d075f46b1eceb90dfc0d6b6f6861efaba 100644 (file)
--- 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 ||
index 62a3ab9ea435dd1ebed58f772f07f6b98b1d3b70..1eb88aac1d4f39371ba5b34fed8e001b19b62b14 100644 (file)
--- 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;