From: Eric Biggers Date: Sun, 18 May 2014 05:43:24 +0000 (-0500) Subject: Don't set FILE_ATTRIBUTE_SPARSE on Windows X-Git-Tag: v1.7.0~133 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=036c7da59a54e9a24b1afb917b4f9f10eee176ee;hp=067245fb775d108fd06b0628935ece5dd94b58ce Don't set FILE_ATTRIBUTE_SPARSE on Windows --- diff --git a/NEWS b/NEWS index 6295bb77..47b5d633 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,8 @@ Version 1.6.3-BETA: The 'mkwinpeimg' script now supports writing the ISO image to standard output. + On Windows, sparse file attributes are no longer set on extracted files. + The shared library version has been bumped up; however, there are only a few incompatibilities: diff --git a/doc/man1/imagex-apply.1.in b/doc/man1/imagex-apply.1.in index 8d3f72a8..cf292773 100644 --- a/doc/man1/imagex-apply.1.in +++ b/doc/man1/imagex-apply.1.in @@ -124,9 +124,10 @@ mode: .IP \[bu] 4 Encrypted files will not be extracted. .IP \[bu] -Although sparse file attributes will be applied, the full data will be extracted -to each sparse file, so extracted "sparse" files may not actually contain any -sparse regions. +wimlib v1.6.3 and later: Sparse file attributes will not be extracted (same +behavior as ImageX/DISM/WIMGAPI). wimlib v1.6.2 and earlier: Although sparse +file attributes will be applied, the full data will be extracted to each sparse +file, so extracted "sparse" files may not actually contain any sparse regions. .PP Regardless, since almost all information from the WIM image is restored in this mode, it is possible to restore an image of an actual Windows installation using diff --git a/src/win32_apply.c b/src/win32_apply.c index d7442686..3f4a4562 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -292,8 +292,10 @@ win32_start_extract(const wchar_t *path, struct apply_ctx *ctx) ctx->supported_features.not_context_indexed_files = 1; +#if 0 if (vol_flags & FILE_SUPPORTS_SPARSE_FILES) ctx->supported_features.sparse_files = 1; +#endif if (vol_flags & FILE_NAMED_STREAMS) ctx->supported_features.named_data_streams = 1; @@ -670,12 +672,27 @@ win32_set_special_file_attributes(const wchar_t *path, u32 attributes) if (h == INVALID_HANDLE_VALUE) goto error; + /* Don't make extracted files sparse. It is pointless without also + * skipping over runs of zeroes when writing the file, and in fact + * increases disk usage --- apparently, allocation sizes in sparse files + * are rounded up to multiples of 131072 bytes rather than 4096 bytes. + * And in some Windows 7 images, *all* files are set as sparse for some + * reason, which causes 1 GB+ of disk space to be wasted on the target + * drive of a full extraction. + * + * WIMGAPI seemingly does not make extracted files sparse either. + * + * XXX: We really ought to do a proper sparse extraction anyway if the + * file meets some heuristic that indicates this would be beneficial. + */ +#if 0 if (attributes & FILE_ATTRIBUTE_SPARSE_FILE) if (!DeviceIoControl(h, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &bytes_returned, NULL)) goto error_close_handle; +#endif if (attributes & FILE_ATTRIBUTE_COMPRESSED) if (!DeviceIoControl(h, FSCTL_SET_COMPRESSION,