- imd_lookup_entry = new_lookup_table_entry();
- if (!imd_lookup_entry) {
- ERROR("Failed to allocate new lookup table entry!\n");
- FREE(imd);
- return WIMLIB_ERR_NOMEM;
- }
-
- imd_lookup_entry->resource_entry.flags = WIM_RESHDR_FLAG_METADATA;
- randomize_byte_array(imd_lookup_entry->hash, WIM_HASH_SIZE);
- lookup_table_insert(w->lookup_table, imd_lookup_entry);
-
+ metadata_lte = new_lookup_table_entry();
+ if (!metadata_lte)
+ goto out_free_imd;
+ sd = CALLOC(1, sizeof(struct wim_security_data));
+ if (!sd)
+ goto out_free_metadata_lte;
+ sd->refcnt = 1;
+ sd->total_length = 8;
+
+ lgt = new_link_group_table(9001);
+ if (!lgt)
+ goto out_free_security_data;
+
+ metadata_lte->resource_entry.flags = WIM_RESHDR_FLAG_METADATA;
+ randomize_byte_array(metadata_lte->hash, WIM_HASH_SIZE);
+ lookup_table_insert(w->lookup_table, metadata_lte);
+
+ new_imd = &imd[w->hdr.image_count];
+
+ new_imd->root_dentry = root_dentry;
+ new_imd->metadata_lte = metadata_lte;
+ new_imd->security_data = sd;
+ new_imd->lgt = lgt;
+ new_imd->modified = true;
+
+ FREE(w->image_metadata);
+ w->image_metadata = imd;