X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fextract.c;h=c1a5adb62aa095417b3b74874385c96456dfa86e;hp=b200e18cae7496df4f88e365085d3abf918c0341;hb=6a84b7d59aa7cc0509ac870e5cbf122c5d755781;hpb=d5a64bb4299105c93b4e9a95e97b579c6f9254af diff --git a/src/extract.c b/src/extract.c index b200e18c..c1a5adb6 100644 --- a/src/extract.c +++ b/src/extract.c @@ -84,7 +84,12 @@ WIMLIB_EXTRACT_FLAG_STRICT_GLOB | \ WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES | \ WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE | \ - WIMLIB_EXTRACT_FLAG_WIMBOOT) + WIMLIB_EXTRACT_FLAG_WIMBOOT | \ + WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K | \ + WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS8K | \ + WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS16K | \ + WIMLIB_EXTRACT_FLAG_COMPACT_LZX \ + ) /* Send WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE or * WIMLIB_PROGRESS_MSG_EXTRACT_METADATA. */ @@ -341,30 +346,9 @@ extract_chunk_wrapper(const void *chunk, size_t size, void *_ctx) if (ret) return ret; - if (progress->extract.completed_bytes >= - progress->extract.total_bytes) - { - ctx->next_progress = UINT64_MAX; - } else { - /* Send new message as soon as another 1/128 of the - * total has been extracted. (Arbitrary number.) */ - ctx->next_progress = - progress->extract.completed_bytes + - progress->extract.total_bytes / 128; - - /* ... Unless that would be more than 5000000 bytes, in - * which case send the next after the next 5000000 - * bytes. (Another arbitrary number.) */ - if (progress->extract.completed_bytes + 5000000 < - ctx->next_progress) - ctx->next_progress = - progress->extract.completed_bytes + 5000000; - - /* ... But always send a message as soon as we're - * completely done. */ - if (progress->extract.total_bytes < ctx->next_progress) - ctx->next_progress = progress->extract.total_bytes; - } + set_next_progress(progress->extract.completed_bytes, + progress->extract.total_bytes, + &ctx->next_progress); } if (unlikely(filedes_valid(&ctx->tmpfile_fd))) { @@ -676,19 +660,20 @@ file_name_valid(utf16lechar *name, size_t num_chars, bool fix) if (num_chars == 0) return true; for (i = 0; i < num_chars; i++) { - switch (name[i]) { + switch (le16_to_cpu(name[i])) { #ifdef __WIN32__ - case cpu_to_le16('\\'): - case cpu_to_le16(':'): - case cpu_to_le16('*'): - case cpu_to_le16('?'): - case cpu_to_le16('"'): - case cpu_to_le16('<'): - case cpu_to_le16('>'): - case cpu_to_le16('|'): + case '\x01'...'\x1F': + case '\\': + case ':': + case '*': + case '?': + case '"': + case '<': + case '>': + case '|': #endif - case cpu_to_le16('/'): - case cpu_to_le16('\0'): + case '/': + case '\0': if (fix) name[i] = replacement_char; else @@ -696,16 +681,6 @@ file_name_valid(utf16lechar *name, size_t num_chars, bool fix) } } -#ifdef __WIN32__ - if (name[num_chars - 1] == cpu_to_le16(' ') || - name[num_chars - 1] == cpu_to_le16('.')) - { - if (fix) - name[num_chars - 1] = replacement_char; - else - return false; - } -#endif return true; } @@ -1003,10 +978,11 @@ ref_stream_if_needed(struct wim_dentry *dentry, struct wim_inode *inode, * - file is a directory * - file is encrypted * - backend needs to create the file as UNIX symlink - * - backend will extract the stream as externally backed + * - backend will extract the stream as externally + * backed from the WIM archive itself */ - if (ctx->apply_ops->will_externally_back) { - int ret = (*ctx->apply_ops->will_externally_back)(dentry, ctx); + if (ctx->apply_ops->will_back_from_wim) { + int ret = (*ctx->apply_ops->will_back_from_wim)(dentry, ctx); if (ret > 0) /* Error? */ return ret; if (ret < 0) /* Won't externally back? */ @@ -1097,12 +1073,14 @@ static void inode_tally_features(const struct wim_inode *inode, struct wim_features *features) { - if (inode->i_attributes & FILE_ATTRIBUTE_ARCHIVE) - features->archive_files++; + if (inode->i_attributes & FILE_ATTRIBUTE_READONLY) + features->readonly_files++; if (inode->i_attributes & FILE_ATTRIBUTE_HIDDEN) features->hidden_files++; if (inode->i_attributes & FILE_ATTRIBUTE_SYSTEM) features->system_files++; + if (inode->i_attributes & FILE_ATTRIBUTE_ARCHIVE) + features->archive_files++; if (inode->i_attributes & FILE_ATTRIBUTE_COMPRESSED) features->compressed_files++; if (inode->i_attributes & FILE_ATTRIBUTE_ENCRYPTED) { @@ -1180,9 +1158,11 @@ do_feature_check(const struct wim_features *required_features, /* File attributes. */ if (!(extract_flags & WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES)) { - /* Note: Don't bother the user about FILE_ATTRIBUTE_ARCHIVE. - * We're an archive program, so theoretically we can do what we - * want with it. */ + + if (required_features->readonly_files && + !supported_features->readonly_files) + WARNING("Ignoring FILE_ATTRIBUTE_READONLY of %lu files", + required_features->readonly_files); if (required_features->hidden_files && !supported_features->hidden_files) @@ -1194,6 +1174,10 @@ do_feature_check(const struct wim_features *required_features, WARNING("Ignoring FILE_ATTRIBUTE_SYSTEM of %lu files", required_features->system_files); + /* Note: Don't bother the user about FILE_ATTRIBUTE_ARCHIVE. + * We're an archive program, so theoretically we can do what we + * want with it. */ + if (required_features->compressed_files && !supported_features->compressed_files) WARNING("Ignoring FILE_ATTRIBUTE_COMPRESSED of %lu files", @@ -1410,12 +1394,12 @@ extract_trees(WIMStruct *wim, struct wim_dentry **trees, size_t num_trees, * subtract from this if hard links are * supported by the extraction mode.) */ ctx->progress.extract.total_bytes = - wim_info_get_image_total_bytes(wim->wim_info, - wim->current_image); + xml_get_image_total_bytes(wim->xml_info, + wim->current_image); if (ctx->supported_features.hard_links) { ctx->progress.extract.total_bytes -= - wim_info_get_image_hard_link_bytes(wim->wim_info, - wim->current_image); + xml_get_image_hard_link_bytes(wim->xml_info, + wim->current_image); } } @@ -1509,6 +1493,34 @@ check_extract_flags(const WIMStruct *wim, int *extract_flags_p) #endif } + if (extract_flags & (WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K | + WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS8K | + WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS16K | + WIMLIB_EXTRACT_FLAG_COMPACT_LZX)) + { + #ifdef __WIN32__ + int count = 0; + count += ((extract_flags & WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS4K) != 0); + count += ((extract_flags & WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS8K) != 0); + count += ((extract_flags & WIMLIB_EXTRACT_FLAG_COMPACT_XPRESS16K) != 0); + count += ((extract_flags & WIMLIB_EXTRACT_FLAG_COMPACT_LZX) != 0); + if (count != 1) { + ERROR("Only one compression format can be specified " + "for compact-mode extraction!"); + return WIMLIB_ERR_INVALID_PARAM; + } + if (extract_flags & WIMLIB_EXTRACT_FLAG_WIMBOOT) { + ERROR("Compact-mode extraction and WIMBoot-mode " + "extraction are mutually exclusive!"); + return WIMLIB_ERR_INVALID_PARAM; + } + #else + ERROR("Compact-mode extraction (System Compression) " + "is only supported on Windows!"); + return WIMLIB_ERR_UNSUPPORTED; + #endif + } + if ((extract_flags & (WIMLIB_EXTRACT_FLAG_RPFIX | WIMLIB_EXTRACT_FLAG_NORPFIX | @@ -1695,7 +1707,8 @@ image_name_ok_as_dir(const tchar *image_name) return image_name && *image_name && !tstrpbrk(image_name, filename_forbidden_chars) && tstrcmp(image_name, T(".")) && - tstrcmp(image_name, T("..")); + tstrcmp(image_name, T("..")) && + tstrlen(image_name) <= 128; } /* Extracts all images from the WIM to the directory @target, with the images @@ -1703,9 +1716,8 @@ image_name_ok_as_dir(const tchar *image_name) static int extract_all_images(WIMStruct *wim, const tchar *target, int extract_flags) { - size_t image_name_max_len = max(xml_get_max_image_name_len(wim), 20); size_t output_path_len = tstrlen(target); - tchar buf[output_path_len + 1 + image_name_max_len + 1]; + tchar buf[output_path_len + 1 + 128 + 1]; int ret; int image; const tchar *image_name; @@ -1861,7 +1873,7 @@ wimlib_extract_image_from_pipe_with_progress(int pipe_fd, if (ret) goto out_wimlib_free; - if (wim_info_get_num_images(pwm->wim_info) != pwm->hdr.image_count) { + if (xml_get_image_count(pwm->xml_info) != pwm->hdr.image_count) { ERROR("Image count in XML data is not the same as in WIM header."); ret = WIMLIB_ERR_IMAGE_COUNT; goto out_wimlib_free; @@ -1925,6 +1937,7 @@ wimlib_extract_image_from_pipe_with_progress(int pipe_fd, goto out_wimlib_free; wim_reshdr_to_desc_and_blob(&reshdr, pwm, metadata_rdesc, imd->metadata_blob); + pwm->refcnt++; if (i == image) { /* Metadata resource is for the image being extracted. @@ -1932,7 +1945,6 @@ wimlib_extract_image_from_pipe_with_progress(int pipe_fd, ret = read_metadata_resource(imd); if (ret) goto out_wimlib_free; - imd->modified = 1; } else { /* Metadata resource is not for the image being * extracted. Skip over it. */