X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fmetadata_resource.c;h=2f7dfeb6e729ce0ae3dd4c0f7a59ca05f9f96e49;hb=18b97ba5b37c0134513886062946d0fd521a9b5e;hp=b55609e667d74e598dc867f576a5a649cc7a0dc8;hpb=1dc6ed6a978ee91dc0be44f70c5dd738696d54fb;p=wimlib diff --git a/src/metadata_resource.c b/src/metadata_resource.c index b55609e6..2f7dfeb6 100644 --- a/src/metadata_resource.c +++ b/src/metadata_resource.c @@ -194,7 +194,7 @@ recalculate_security_data_length(struct wim_security_data *sd) * the buffer to @hash. */ static int write_wim_resource_from_buffer(const void *buf, size_t buf_size, - filedes_t out_fd, int out_ctype, + int out_fd, int out_ctype, struct resource_entry *out_res_entry, u8 hash[SHA1_HASH_SIZE]) { @@ -225,16 +225,26 @@ write_metadata_resource(WIMStruct *w) struct wim_lookup_table_entry *lte; u64 metadata_original_size; struct wim_security_data *sd; + struct wim_image_metadata *imd; - wimlib_assert(w->out_fd != INVALID_FILEDES); + wimlib_assert(w->out_fd != -1); wimlib_assert(w->current_image != WIMLIB_NO_IMAGE); DEBUG("Writing metadata resource for image %d (offset = %"PRIu64")", w->current_image, filedes_offset(w->out_fd)); + imd = w->image_metadata[w->current_image - 1]; - root = wim_root_dentry(w); - sd = wim_security_data(w); + root = imd->root_dentry; + sd = imd->security_data; + + if (!root) { + /* Empty image; create a dummy root. */ + ret = new_filler_directory(T(""), &root); + if (ret) + return ret; + imd->root_dentry = root; + } /* Offset of first child of the root dentry. It's equal to: * - The total length of the security data, rounded to the next 8-byte