+
+ if (st->update_tail) {
+ /* queue the virtual_disk and vd_config as metadata updates */
+ struct virtual_disk *vd;
+ struct vd_config *vc;
+ struct ddf_super *ddf = st->sb;
+ int len;
+
+ if (!ddf->currentconf) {
+ int len = (sizeof(struct phys_disk) +
+ sizeof(struct phys_disk_entry));
+
+ /* adding a disk to the container. */
+ if (!ddf->add_list)
+ return 0;
+
+ append_metadata_update(st, ddf->add_list->mdupdate, len);
+ ddf->add_list->mdupdate = NULL;
+ return 0;
+ }
+
+ /* Newly created VD */
+
+ /* First the virtual disk. We have a slightly fake header */
+ len = sizeof(struct virtual_disk) + sizeof(struct virtual_entry);
+ vd = malloc(len);
+ *vd = *ddf->virt;
+ vd->entries[0] = ddf->virt->entries[ddf->currentconf->vcnum];
+ vd->populated_vdes = __cpu_to_be16(ddf->currentconf->vcnum);
+ append_metadata_update(st, vd, len);
+
+ /* Then the vd_config */
+ len = ddf->conf_rec_len * 512;
+ vc = malloc(len);
+ memcpy(vc, &ddf->currentconf->conf, len);
+ append_metadata_update(st, vc, len);
+
+ /* FIXME I need to close the fds! */
+ return 0;
+ } else
+ return __write_init_super_ddf(st, 1);