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,
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++) {
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);
}
}
+static void export_examine_super_imsm(struct supertype *st)
+{
+ struct intel_super *super = st->sb;
+ struct imsm_super *mpb = super->anchor;
+ struct mdinfo info;
+ char nbuf[64];
+
+ getinfo_super_imsm(st, &info);
+ fname_from_uuid(st, &info, nbuf, ':');
+ printf("MD_METADATA=imsm\n");
+ printf("MD_LEVEL=container\n");
+ printf("MD_UUID=%s\n", nbuf+5);
+ printf("MD_DEVICES=%u\n", mpb->num_disks);
+}
+
static void detail_super_imsm(struct supertype *st, char *homehost)
{
struct mdinfo info;
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);
}
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);
}
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));
return rv;
}
- /* trim leading whitespace */
rsp_len = scsi_serial[3];
if (!rsp_len) {
if (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;
}
if (posix_memalign(&buf, 512, len) != 0)
return 1;
- memcpy(buf, super->buf, len);
+ memcpy(buf, super->buf, super->len);
+ memset(buf + super->len, 0, len - super->len);
free(super->buf);
super->buf = buf;
super->len = len;
return info->chunk_size >> 9;
}
-static __u32 info_to_num_data_stripes(mdu_array_info_t *info)
+static __u32 info_to_num_data_stripes(mdu_array_info_t *info, int num_domains)
{
__u32 num_stripes;
num_stripes = (info->size * 2) / info_to_blocks_per_strip(info);
- if (info->level == 1)
- num_stripes /= 2;
+ num_stripes /= num_domains;
return num_stripes;
}
int i;
unsigned long long array_blocks;
size_t size_old, size_new;
+ __u32 num_data_stripes;
if (super->orom && mpb->num_raid_devs >= super->orom->vpa) {
fprintf(stderr, Name": This imsm-container already has the "
map->pba_of_lba0 = __cpu_to_le32(super->create_offset);
map->blocks_per_member = __cpu_to_le32(info_to_blocks_per_member(info));
map->blocks_per_strip = __cpu_to_le16(info_to_blocks_per_strip(info));
- map->num_data_stripes = __cpu_to_le32(info_to_num_data_stripes(info));
map->failed_disk_num = ~0;
map->map_state = info->level ? IMSM_T_STATE_UNINITIALIZED :
IMSM_T_STATE_NORMAL;
map->num_domains = info->raid_disks / 2;
} else {
map->raid_level = info->level;
- map->num_domains = !!map->raid_level;
+ map->num_domains = 1;
}
+ num_data_stripes = info_to_num_data_stripes(info, map->num_domains);
+ map->num_data_stripes = __cpu_to_le32(num_data_stripes);
map->num_members = info->raid_disks;
for (i = 0; i < map->num_members; i++) {
free(super->next_buf);
super->next_len = buf_len;
- if (posix_memalign(&super->next_buf, 512, buf_len) != 0)
+ if (posix_memalign(&super->next_buf, 512, buf_len) == 0)
+ memset(super->next_buf, 0, buf_len);
+ else
super->next_buf = NULL;
}
}
#ifndef MDASSEMBLE
.examine_super = examine_super_imsm,
.brief_examine_super = brief_examine_super_imsm,
+ .export_examine_super = export_examine_super_imsm,
.detail_super = detail_super_imsm,
.brief_detail_super = brief_detail_super_imsm,
.write_init_super = write_init_super_imsm,