]> wimlib.net Git - wimlib/blobdiff - src/extract.c
dentry_extract_skeleton(): Fix bug with DOS name reordering
[wimlib] / src / extract.c
index 1784cdf500e9024bba60b4cf33e1725bc9f0d2ee..ae591bbef6f33cf41d9b5d407b054de35a871b58 100644 (file)
@@ -53,7 +53,6 @@
 #include "wimlib/reparse.h"
 #include "wimlib/resource.h"
 #include "wimlib/security.h"
-#include "wimlib/swm.h"
 #ifdef __WIN32__
 #  include "wimlib/win32.h" /* for realpath() equivalent */
 #endif
@@ -1144,7 +1143,8 @@ dentry_extract_skeleton(struct wim_dentry *dentry, void *_ctx)
        {
                inode_for_each_dentry(other_dentry, dentry->d_inode) {
                        if (dentry_has_short_name(other_dentry)
-                           && !other_dentry->skeleton_extracted)
+                           && !other_dentry->skeleton_extracted
+                           && other_dentry->in_extraction_tree)
                        {
                                DEBUG("Creating %"TS" before %"TS" "
                                      "to guarantee correct DOS name extraction",
@@ -1427,7 +1427,7 @@ extract_streams_from_pipe(struct apply_ctx *ctx)
 
                if ((found_lte->resource_location != RESOURCE_NONEXISTENT)
                    && !(found_lte->resource_entry.flags & WIM_RESHDR_FLAG_METADATA)
-                   && (needed_lte = __lookup_resource(lookup_table, found_lte->hash))
+                   && (needed_lte = lookup_resource(lookup_table, found_lte->hash))
                    && (needed_lte->out_refcnt))
                {
                        copy_resource_entry(&needed_lte->resource_entry,
@@ -1624,6 +1624,8 @@ dentry_calculate_extraction_path(struct wim_dentry *dentry, void *_args)
        struct apply_ctx *ctx = _args;
        int ret;
 
+       dentry->in_extraction_tree = 1;
+
        if (dentry == ctx->extract_root || dentry->extraction_skipped)
                return 0;
 
@@ -1743,6 +1745,7 @@ dentry_reset_needs_extraction(struct wim_dentry *dentry, void *_ignore)
 {
        struct wim_inode *inode = dentry->d_inode;
 
+       dentry->in_extraction_tree = 0;
        dentry->extraction_skipped = 0;
        dentry->was_hardlinked = 0;
        dentry->skeleton_extracted = 0;
@@ -1802,20 +1805,13 @@ dentry_tally_features(struct wim_dentry *dentry, void *_features)
        return 0;
 }
 
-static int
-dentry_clear_inode_visited(struct wim_dentry *dentry, void *_ignore)
-{
-       dentry->d_inode->i_visited = 0;
-       return 0;
-}
-
 /* Tally the features necessary to extract a dentry tree.  */
 static void
 dentry_tree_get_features(struct wim_dentry *root, struct wim_features *features)
 {
        memset(features, 0, sizeof(struct wim_features));
        for_dentry_in_tree(root, dentry_tally_features, features);
-       for_dentry_in_tree(root, dentry_clear_inode_visited, NULL);
+       dentry_tree_clear_inode_visited(root);
 }
 
 static u32
@@ -2568,8 +2564,6 @@ wimlib_extract_files(WIMStruct *wim,
                     const struct wimlib_extract_command *cmds,
                     size_t num_cmds,
                     int default_extract_flags,
-                    WIMStruct **additional_swms,
-                    unsigned num_additional_swms,
                     wimlib_progress_func_t progress_func)
 {
        int ret;
@@ -2578,21 +2572,12 @@ wimlib_extract_files(WIMStruct *wim,
 
        default_extract_flags &= WIMLIB_EXTRACT_MASK_PUBLIC;
 
-       ret = verify_swm_set(wim, additional_swms, num_additional_swms);
-       if (ret)
-               goto out;
-
        if (num_cmds == 0)
-               goto out;
-
-       if (num_additional_swms)
-               merge_lookup_tables(wim, additional_swms, num_additional_swms);
+               return 0;
 
        cmds_copy = CALLOC(num_cmds, sizeof(cmds[0]));
-       if (!cmds_copy) {
-               ret = WIMLIB_ERR_NOMEM;
-               goto out_restore_lookup_table;
-       }
+       if (!cmds_copy)
+               return WIMLIB_ERR_NOMEM;
 
        for (size_t i = 0; i < num_cmds; i++) {
                cmds_copy[i].extract_flags = (default_extract_flags |
@@ -2629,10 +2614,6 @@ out_free_cmds_copy:
                FREE(cmds_copy[i].fs_dest_path);
        }
        FREE(cmds_copy);
-out_restore_lookup_table:
-       if (num_additional_swms)
-               unmerge_lookup_table(wim);
-out:
        return ret;
 }
 
@@ -2753,24 +2734,10 @@ do_wimlib_extract_image(WIMStruct *wim,
                        int image,
                        const tchar *target,
                        int extract_flags,
-                       WIMStruct **additional_swms,
-                       unsigned num_additional_swms,
                        wimlib_progress_func_t progress_func)
 {
        int ret;
 
-       if (extract_flags & WIMLIB_EXTRACT_FLAG_FROM_PIPE) {
-               wimlib_assert(wim->hdr.part_number == 1);
-               wimlib_assert(num_additional_swms == 0);
-       } else {
-               ret = verify_swm_set(wim, additional_swms, num_additional_swms);
-               if (ret)
-                       return ret;
-
-               if (num_additional_swms)
-                       merge_lookup_tables(wim, additional_swms, num_additional_swms);
-       }
-
        if (image == WIMLIB_ALL_IMAGES) {
                ret = extract_all_images(wim, target, extract_flags,
                                         progress_func);
@@ -2786,8 +2753,6 @@ do_wimlib_extract_image(WIMStruct *wim,
                                       lte_free_extracted_file,
                                       NULL);
        }
-       if (num_additional_swms)
-               unmerge_lookup_table(wim);
        return ret;
 }
 
@@ -2815,8 +2780,7 @@ wimlib_extract_image_from_pipe(int pipe_fd, const tchar *image_num_or_name,
         * wimlib_open_wim(), getting a WIMStruct in this way will result in
         * an empty lookup table, no XML data read, and no filename set.  */
        ret = open_wim_as_WIMStruct(&pipe_fd,
-                                   WIMLIB_OPEN_FLAG_FROM_PIPE |
-                                               WIMLIB_OPEN_FLAG_SPLIT_OK,
+                                   WIMLIB_OPEN_FLAG_FROM_PIPE,
                                    &pwm, progress_func);
        if (ret)
                return ret;
@@ -2941,7 +2905,7 @@ wimlib_extract_image_from_pipe(int pipe_fd, const tchar *image_num_or_name,
        /* Extract the image.  */
        extract_flags |= WIMLIB_EXTRACT_FLAG_FROM_PIPE;
        ret = do_wimlib_extract_image(pwm, image, target,
-                                     extract_flags, NULL, 0, progress_func);
+                                     extract_flags, progress_func);
        /* Clean up and return.  */
 out_wimlib_free:
        wimlib_free(pwm);
@@ -2954,12 +2918,9 @@ wimlib_extract_image(WIMStruct *wim,
                     int image,
                     const tchar *target,
                     int extract_flags,
-                    WIMStruct **additional_swms,
-                    unsigned num_additional_swms,
                     wimlib_progress_func_t progress_func)
 {
        extract_flags &= WIMLIB_EXTRACT_MASK_PUBLIC;
        return do_wimlib_extract_image(wim, image, target, extract_flags,
-                                      additional_swms, num_additional_swms,
                                       progress_func);
 }