+static struct mdinfo *container_content_ddf(struct supertype *st)
+{
+ /* Given a container loaded by load_super_ddf_all,
+ * extract information about all the arrays into
+ * an mdinfo tree.
+ *
+ * For each vcl in conflist: create an mdinfo, fill it in,
+ * then look for matching devices (phys_refnum) in dlist
+ * and create appropriate device mdinfo.
+ */
+ struct ddf_super *ddf = st->sb;
+ struct mdinfo *rest = NULL;
+ struct vcl *vc;
+
+ for (vc = ddf->conflist ; vc ; vc=vc->next)
+ {
+ int mppe;
+ int i;
+ struct mdinfo *this;
+ this = malloc(sizeof(*this));
+ memset(this, 0, sizeof(*this));
+ this->next = rest;
+ rest = this;
+
+ this->array.major_version = 1000;
+ this->array.minor_version = 0;
+ this->array.patch_version = 0;
+ this->array.level = map_num1(ddf_level_num, vc->conf.prl);
+ this->array.raid_disks =
+ __be16_to_cpu(vc->conf.prim_elmnt_count);
+ /* FIXME this should be mapped */
+ this->array.layout = vc->conf.rlq;
+ this->array.md_minor = -1;
+ this->array.ctime = DECADE +
+ __be32_to_cpu(*(__u32*)(vc->conf.guid+16));
+ this->array.utime = DECADE +
+ __be32_to_cpu(vc->conf.timestamp);
+ this->array.chunk_size = 512 << vc->conf.chunk_shift;
+
+ for (i=0; i < __be16_to_cpu(ddf->virt->populated_vdes); i++)
+ if (memcmp(ddf->virt->entries[i].guid,
+ vc->conf.guid, DDF_GUID_LEN) == 0)
+ break;
+ if (ddf->virt->entries[i].state & DDF_state_inconsistent)
+ this->array.state = 0;
+ else
+ this->array.state = 1;
+ memcpy(this->name, ddf->virt->entries[i].name, 32);
+ this->name[33]=0;
+
+ memset(this->uuid, 0, sizeof(this->uuid));
+ this->component_size = __be64_to_cpu(vc->conf.blocks);
+ this->array.size = this->component_size / 2;
+
+ mppe = __be16_to_cpu(ddf->anchor.max_primary_element_entries);
+ for (i=0 ; i < mppe ; i++) {
+ struct mdinfo *dev;
+ struct dl *d;
+
+ if (vc->conf.phys_refnum[i] == 0xFFFFFFFF)
+ continue;
+
+ this->array.working_disks++;
+
+ for (d = ddf->dlist; d ; d=d->next)
+ if (d->disk.refnum == vc->conf.phys_refnum[i])
+ break;
+ if (d == NULL)
+ break;
+
+ dev = malloc(sizeof(*dev));
+ memset(dev, 0, sizeof(*dev));
+ dev->next = this->devs;
+ this->devs = dev;
+
+ dev->disk.number = __be32_to_cpu(d->disk.refnum);
+ dev->disk.major = d->major;
+ dev->disk.minor = d->minor;
+ dev->disk.raid_disk = i;
+ dev->disk.state = (1<<MD_DISK_SYNC)|(1<<MD_DISK_ACTIVE);
+
+ dev->events = __le32_to_cpu(ddf->primary.seq);
+ dev->data_offset = vc->lba_offset[i];
+ dev->component_size = __be64_to_cpu(vc->conf.blocks);
+ if (d->devname)
+ strcpy(dev->name, d->devname);
+ }
+ }
+ return rest;
+}
+