]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-intel.c
imsm: make uuid separator consistent with ddf
[thirdparty/mdadm.git] / super-intel.c
index 9c4f0eb56c19836a59016599335bc0fea81ac81a..b47b64b52c5bc15537f7543725e58c78505320eb 100644 (file)
@@ -679,7 +679,7 @@ static void examine_super_imsm(struct supertype *st, char *homehost)
        printf("         Family : %08x\n", __le32_to_cpu(mpb->family_num));
        printf("     Generation : %08x\n", __le32_to_cpu(mpb->generation_num));
        getinfo_super_imsm(st, &info);
-       fname_from_uuid(st, &info, nbuf,'-');
+       fname_from_uuid(st, &info, nbuf, ':');
        printf("           UUID : %s\n", nbuf + 5);
        sum = __le32_to_cpu(mpb->check_sum);
        printf("       Checksum : %08x %s\n", sum,
@@ -705,7 +705,7 @@ static void examine_super_imsm(struct supertype *st, char *homehost)
 
                super->current_vol = i;
                getinfo_super_imsm(st, &info);
-               fname_from_uuid(st, &info, nbuf, '-');
+               fname_from_uuid(st, &info, nbuf, ':');
                print_imsm_dev(dev, nbuf + 5, super->disks->index);
        }
        for (i = 0; i < mpb->num_disks; i++) {
@@ -728,14 +728,14 @@ static void brief_examine_super_imsm(struct supertype *st)
                return;
 
        getinfo_super_imsm(st, &info);
-       fname_from_uuid(st, &info, nbuf,'-');
+       fname_from_uuid(st, &info, nbuf, ':');
        printf("ARRAY metadata=imsm auto=md UUID=%s\n", nbuf + 5);
        for (i = 0; i < super->anchor->num_raid_devs; i++) {
                struct imsm_dev *dev = get_imsm_dev(super, i);
 
                super->current_vol = i;
                getinfo_super_imsm(st, &info);
-               fname_from_uuid(st, &info, nbuf1,'-');
+               fname_from_uuid(st, &info, nbuf1, ':');
                printf("ARRAY /dev/md/%.16s container=%s\n"
                       "   member=%d auto=mdp UUID=%s\n",
                       dev->volume, nbuf + 5, i, nbuf1 + 5);
@@ -748,7 +748,7 @@ static void detail_super_imsm(struct supertype *st, char *homehost)
        char nbuf[64];
 
        getinfo_super_imsm(st, &info);
-       fname_from_uuid(st, &info, nbuf,'-');
+       fname_from_uuid(st, &info, nbuf, ':');
        printf("\n           UUID : %s\n", nbuf + 5);
 }
 
@@ -757,7 +757,7 @@ static void brief_detail_super_imsm(struct supertype *st)
        struct mdinfo info;
        char nbuf[64];
        getinfo_super_imsm(st, &info);
-       fname_from_uuid(st, &info, nbuf,'-');
+       fname_from_uuid(st, &info, nbuf, ':');
        printf(" UUID=%s", nbuf + 5);
 }
 
@@ -1461,7 +1461,10 @@ static int imsm_read_serial(int fd, char *devname,
        int rv;
        int rsp_len;
        int len;
-       char *c, *rsp_buf;
+       char *dest;
+       char *src;
+       char *rsp_buf;
+       int i;
 
        memset(scsi_serial, 0, sizeof(scsi_serial));
 
@@ -1481,7 +1484,6 @@ static int imsm_read_serial(int fd, char *devname,
                return rv;
        }
 
-       /* trim leading whitespace */
        rsp_len = scsi_serial[3];
        if (!rsp_len) {
                if (devname)
@@ -1491,24 +1493,33 @@ static int imsm_read_serial(int fd, char *devname,
                return 2;
        }
        rsp_buf = (char *) &scsi_serial[4];
-       c = rsp_buf;
-       while (isspace(*c))
-               c++;
 
-       /* truncate len to the end of rsp_buf if necessary */
-       if (c + MAX_RAID_SERIAL_LEN > rsp_buf + rsp_len)
-               len = rsp_len - (c - rsp_buf);
-       else
+       /* trim all whitespace and non-printable characters and convert
+        * ':' to ';'
+        */
+       for (i = 0, dest = rsp_buf; i < rsp_len; i++) {
+               src = &rsp_buf[i];
+               if (*src > 0x20) {
+                       /* ':' is reserved for use in placeholder serial
+                        * numbers for missing disks
+                        */
+                       if (*src == ':')
+                               *dest++ = ';';
+                       else
+                               *dest++ = *src;
+               }
+       }
+       len = dest - rsp_buf;
+       dest = rsp_buf;
+
+       /* truncate leading characters */
+       if (len > MAX_RAID_SERIAL_LEN) {
+               dest += len - MAX_RAID_SERIAL_LEN;
                len = MAX_RAID_SERIAL_LEN;
+       }
 
-       /* initialize the buffer and copy rsp_buf characters */
        memset(serial, 0, MAX_RAID_SERIAL_LEN);
-       memcpy(serial, c, len);
-
-       /* trim trailing whitespace starting with the last character copied */
-       c = (char *) &serial[len - 1];
-       while (isspace(*c) || *c == '\0')
-               *c-- = '\0';
+       memcpy(serial, dest, len);
 
        return 0;
 }
@@ -2830,7 +2841,7 @@ static unsigned long long merge_extents(struct intel_super *super, int sum_exten
        int i, j;
        int start_extent;
        unsigned long long pos;
-       unsigned long long start;
+       unsigned long long start = 0;
        unsigned long long maxsize;
        unsigned long reserve;