X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwim.c;h=3676123a9b58ce8c8149d9633eed68d5c0bee24a;hp=f91c98bc4b0b7d12add9c585c4314966a3493070;hb=d4f8cc3998aebb08c6cd12d248173323b43c07b8;hpb=da295f258b60e1593de305385c0669eac4b76644 diff --git a/src/wim.c b/src/wim.c index f91c98bc..3676123a 100644 --- a/src/wim.c +++ b/src/wim.c @@ -71,7 +71,7 @@ new_wim_struct(void) wim->in_fd.fd = -1; wim->out_fd.fd = -1; } - INIT_LIST_HEAD(&wim->resource_wims); + INIT_LIST_HEAD(&wim->subwims); return wim; } @@ -333,8 +333,10 @@ wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info, int whic if (ret) return ret; - if (which & WIMLIB_CHANGE_GUID) + if (which & WIMLIB_CHANGE_GUID) { memcpy(wim->hdr.guid, info->guid, WIM_GID_LEN); + wim->guid_set_explicitly = 1; + } if (which & WIMLIB_CHANGE_BOOT_INDEX) { if (info->boot_index > wim->hdr.image_count) { @@ -418,7 +420,7 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, * intervening time... * * Warning: in Windows native builds, realpath() calls the - * replacement function in win32.c. + * replacement function in win32_replacements.c. */ wim->filename = realpath(wimfile, NULL); if (!wim->filename) { @@ -446,11 +448,9 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, return ret; } - if (wim->hdr.total_parts != 1 && !(open_flags & WIMLIB_OPEN_FLAG_SPLIT_OK)) { - ERROR("\"%"TS"\": This WIM is part %u of a %u-part WIM", - wimfile, wim->hdr.part_number, wim->hdr.total_parts); - return WIMLIB_ERR_SPLIT_UNSUPPORTED; - } + if ((open_flags & WIMLIB_OPEN_FLAG_ERROR_IF_SPLIT) && + (wim->hdr.total_parts != 1)) + return WIMLIB_ERR_IS_SPLIT_WIM; DEBUG("According to header, WIM contains %u images", wim->hdr.image_count); @@ -680,6 +680,9 @@ int wim_checksum_unhashed_streams(WIMStruct *wim) { int ret; + + if (!wim_has_metadata(wim)) + return 0; for (int i = 0; i < wim->hdr.image_count; i++) { struct wim_lookup_table_entry *lte, *tmp; struct wim_image_metadata *imd = wim->image_metadata[i]; @@ -712,7 +715,7 @@ can_modify_wim(WIMStruct *wim) } } if (wim->hdr.total_parts != 1) { - ERROR("Cannot modify \"%"TS"\": is part of a spanned set", + ERROR("Cannot modify \"%"TS"\": is part of a split WIM", wim->filename); return WIMLIB_ERR_WIM_IS_READONLY; } @@ -752,22 +755,19 @@ can_delete_from_wim(WIMStruct *wim) WIMLIBAPI void wimlib_free(WIMStruct *wim) { - DEBUG("Freeing WIMStruct"); - if (!wim) return; - while (!list_empty(&wim->resource_wims)) { - WIMStruct *resource_wim; + DEBUG("Freeing WIMStruct (filename=\"%"TS"\", image_count=%u)", + wim->filename, wim->hdr.image_count); - resource_wim = list_entry(wim->resource_wims.next, - WIMStruct, resource_wim_node); - if (resource_wim->is_owned_by_master) { - list_del(&resource_wim->resource_wim_node); - wimlib_free(resource_wim); - } else { - wimlib_unreference_resources(wim, &resource_wim, 1); - } + while (!list_empty(&wim->subwims)) { + WIMStruct *subwim; + + subwim = list_entry(wim->subwims.next, WIMStruct, subwim_node); + list_del(&subwim->subwim_node); + DEBUG("Freeing subwim."); + wimlib_free(subwim); } if (filedes_valid(&wim->in_fd)) @@ -786,7 +786,6 @@ wimlib_free(WIMStruct *wim) FREE(wim->image_metadata); } FREE(wim); - DEBUG("Freed WIMStruct"); } static bool