X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fextract.c;h=3e4fbcc88fca43e94d489aea8de3b11591548d3c;hb=c73468ab9d94f48a801008ea4fb15de6880c44e8;hp=5c2f0f7176f92b16786707193749400c72312d7c;hpb=90a8c3e8ef04ec9b5eb210cbd44bc8c501c504e9;p=wimlib diff --git a/src/extract.c b/src/extract.c index 5c2f0f71..3e4fbcc8 100644 --- a/src/extract.c +++ b/src/extract.c @@ -93,7 +93,7 @@ dentry_resolve_and_zero_lte_refcnt(struct wim_dentry *dentry, void *_ctx) * "resolve" the inode's streams anyway by allocating new entries. */ if (ctx->extract_flags & WIMLIB_EXTRACT_FLAG_FROM_PIPE) force = true; - ret = inode_resolve_ltes(inode, ctx->wim->lookup_table, force); + ret = inode_resolve_streams(inode, ctx->wim->lookup_table, force); if (ret) return ret; for (unsigned i = 0; i <= inode->i_num_ads; i++) { @@ -1147,7 +1147,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->in_extraction_tree) + && other_dentry->in_extraction_tree + && !other_dentry->extraction_skipped) { DEBUG("Creating %"TS" before %"TS" " "to guarantee correct DOS name extraction", @@ -1507,7 +1508,7 @@ extract_streams_from_pipe(struct apply_ctx *ctx) if ((found_lte->resource_location != RESOURCE_NONEXISTENT) && !(found_lte->flags & WIM_RESHDR_FLAG_METADATA) - && (needed_lte = lookup_resource(lookup_table, found_lte->hash)) + && (needed_lte = lookup_stream(lookup_table, found_lte->hash)) && (needed_lte->out_refcnt)) { tchar *tmpfile_name = NULL; @@ -1527,8 +1528,10 @@ extract_streams_from_pipe(struct apply_ctx *ctx) /* Extract stream to temporary file. */ ret = create_temporary_file(&tmpfile_fd, &tmpfile_name); - if (ret) + if (ret) { + lte_unbind_wim_resource_spec(needed_lte); goto out_free_found_lte; + } ret = extract_full_stream_to_fd(needed_lte, &tmpfile_fd); @@ -1704,17 +1707,6 @@ file_name_valid(utf16lechar *name, size_t num_chars, bool fix) return true; } -static bool -dentry_is_dot_or_dotdot(const struct wim_dentry *dentry) -{ - const utf16lechar *file_name = dentry->file_name; - return file_name != NULL && - file_name[0] == cpu_to_le16('.') && - (file_name[1] == cpu_to_le16('\0') || - (file_name[1] == cpu_to_le16('.') && - file_name[2] == cpu_to_le16('\0'))); -} - static int dentry_mark_skipped(struct wim_dentry *dentry, void *_ignore) { @@ -1752,14 +1744,6 @@ dentry_calculate_extraction_path(struct wim_dentry *dentry, void *_args) if (!dentry_is_supported(dentry, &ctx->supported_features)) goto skip_dentry; - if (dentry_is_dot_or_dotdot(dentry)) { - /* WIM files shouldn't contain . or .. entries. But if they are - * there, don't attempt to extract them. */ - WARNING("Skipping extraction of unexpected . or .. file " - "\"%"TS"\"", dentry_full_path(dentry)); - goto skip_dentry; - } - if (!ctx->ops->supports_case_sensitive_filenames) { struct wim_dentry *other; @@ -2374,7 +2358,12 @@ extract_trees(WIMStruct *wim, struct wim_dentry **trees, size_t num_trees, * directory tree. (If not, extract_dentry_to_stdout() will * return an error.) */ if (extract_flags & WIMLIB_EXTRACT_FLAG_TO_STDOUT) { - ret = extract_dentry_to_stdout(ctx.extract_root); + ret = 0; + for (size_t i = 0; i < num_trees; i++) { + ret = extract_dentry_to_stdout(trees[i]); + if (ret) + break; + } goto out_teardown_stream_list; } @@ -3170,11 +3159,6 @@ wimlib_extract_paths(WIMStruct *wim, wimlib_progress_func_t progress_func) { int ret; - struct append_dentry_ctx append_dentry_ctx = { - .dentries = NULL, - .num_dentries = 0, - .num_alloc_dentries = 0, - }; struct wim_dentry **trees; size_t num_trees; @@ -3194,6 +3178,13 @@ wimlib_extract_paths(WIMStruct *wim, return ret; if (extract_flags & WIMLIB_EXTRACT_FLAG_GLOB_PATHS) { + + struct append_dentry_ctx append_dentry_ctx = { + .dentries = NULL, + .num_dentries = 0, + .num_alloc_dentries = 0, + }; + u32 wildcard_flags = 0; if (extract_flags & WIMLIB_EXTRACT_FLAG_STRICT_GLOB) @@ -3205,10 +3196,17 @@ wimlib_extract_paths(WIMStruct *wim, wildcard_flags |= WILDCARD_FLAG_CASE_INSENSITIVE; for (size_t i = 0; i < num_paths; i++) { - ret = expand_wildcard(wim, paths[i], + tchar *path = canonicalize_wim_path(paths[i]); + if (path == NULL) { + ret = WIMLIB_ERR_NOMEM; + trees = append_dentry_ctx.dentries; + goto out_free_trees; + } + ret = expand_wildcard(wim, path, append_dentry_cb, &append_dentry_ctx, wildcard_flags); + FREE(path); if (ret) { trees = append_dentry_ctx.dentries; goto out_free_trees; @@ -3222,8 +3220,16 @@ wimlib_extract_paths(WIMStruct *wim, return WIMLIB_ERR_NOMEM; for (size_t i = 0; i < num_paths; i++) { - trees[i] = get_dentry(wim, paths[i], + + tchar *path = canonicalize_wim_path(paths[i]); + if (path == NULL) { + ret = WIMLIB_ERR_NOMEM; + goto out_free_trees; + } + + trees[i] = get_dentry(wim, path, WIMLIB_CASE_PLATFORM_DEFAULT); + FREE(path); if (trees[i] == NULL) { ERROR("Path \"%"TS"\" does not exist " "in WIM image %d", @@ -3246,6 +3252,14 @@ wimlib_extract_paths(WIMStruct *wim, ~WIMLIB_EXTRACT_FLAG_GLOB_PATHS) | WIMLIB_EXTRACT_FLAG_PATHMODE), progress_func); + + if (extract_flags & (WIMLIB_EXTRACT_FLAG_SYMLINK | + WIMLIB_EXTRACT_FLAG_HARDLINK)) + { + for_lookup_table_entry(wim->lookup_table, + lte_free_extracted_file, + NULL); + } out_free_trees: FREE(trees); return ret;