X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwim.c;h=128bddac428e50f9260d4d8f9b8d0ce7fd7419b8;hb=bdc18020a46938f142bf39f10f9e0f1c9126cb0b;hp=ed20145e2b452aad3ce511b5f5f754aecf6b269b;hpb=13c6ce3160fce7c40008d1d182325c8b42450d1e;p=wimlib diff --git a/src/wim.c b/src/wim.c index ed20145e..128bddac 100644 --- a/src/wim.c +++ b/src/wim.c @@ -32,11 +32,6 @@ #include #include -#ifdef WITH_NTFS_3G -# include -# include -#endif - #ifdef __WIN32__ # include "win32.h" #else @@ -199,6 +194,7 @@ select_wim_image(WIMStruct *w, int image) if (w->current_image != WIMLIB_NO_IMAGE) { imd = wim_get_current_image_metadata(w); if (!imd->modified) { + wimlib_assert(list_empty(&imd->unhashed_streams)); DEBUG("Freeing image %u", w->current_image); destroy_image_metadata(imd, NULL, false); } @@ -532,8 +528,19 @@ destroy_image_metadata(struct wim_image_metadata *imd, free_lookup_table_entry(imd->metadata_lte); imd->metadata_lte = NULL; } + if (!table) { + struct wim_lookup_table_entry *lte, *tmp; + list_for_each_entry_safe(lte, tmp, &imd->unhashed_streams, unhashed_list) + free_lookup_table_entry(lte); + } INIT_LIST_HEAD(&imd->unhashed_streams); - INIT_HLIST_HEAD(&imd->inode_list); + INIT_LIST_HEAD(&imd->inode_list); +#ifdef WITH_NTFS_3G + if (imd->ntfs_vol) { + do_ntfs_umount(imd->ntfs_vol); + imd->ntfs_vol = NULL; + } +#endif } void @@ -570,11 +577,11 @@ struct wim_image_metadata * new_image_metadata() { struct wim_image_metadata *imd; - + imd = CALLOC(1, sizeof(*imd)); if (imd) { imd->refcnt = 1; - INIT_HLIST_HEAD(&imd->inode_list); + INIT_LIST_HEAD(&imd->inode_list); INIT_LIST_HEAD(&imd->unhashed_streams); DEBUG("Created new image metadata (refcnt=1)"); } else { @@ -610,6 +617,24 @@ new_image_metadata_array(unsigned num_images) return imd_array; } +int +wim_checksum_unhashed_streams(WIMStruct *w) +{ + int ret; + for (int i = 0; i < w->hdr.image_count; i++) { + struct wim_lookup_table_entry *lte, *tmp; + list_for_each_entry_safe(lte, tmp, + &w->image_metadata[i]->unhashed_streams, + unhashed_list) + { + ret = hash_unhashed_stream(lte, w->lookup_table, NULL); + if (ret) + return ret; + } + } + return 0; +} + /* Frees the memory for the WIMStruct, including all internal memory; also * closes all files associated with the WIMStruct. */ WIMLIBAPI void @@ -644,12 +669,6 @@ wimlib_free(WIMStruct *w) put_image_metadata(w->image_metadata[i], NULL); FREE(w->image_metadata); } -#ifdef WITH_NTFS_3G - if (w->ntfs_vol) { - DEBUG("Unmounting NTFS volume"); - ntfs_umount(w->ntfs_vol, FALSE); - } -#endif FREE(w); DEBUG("Freed WIMStruct"); }