]> wimlib.net Git - wimlib/commitdiff
Don't set FILE_ATTRIBUTE_SPARSE on Windows
authorEric Biggers <ebiggers3@gmail.com>
Sun, 18 May 2014 05:43:24 +0000 (00:43 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 18 May 2014 05:43:24 +0000 (00:43 -0500)
NEWS
doc/man1/imagex-apply.1.in
src/win32_apply.c

diff --git a/NEWS b/NEWS
index 6295bb77059166d10f778dc286734905031a41c6..47b5d63343bf272e5cba24a7ed9347b6980210a8 100644 (file)
--- 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.
 
        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:
 
        The shared library version has been bumped up; however, there are only a
        few incompatibilities:
 
index 8d3f72a867786c64f264e0787a2ff8f64c4f7aa0..cf29277351d320dc7b9a1e2ba5ec674f57c64852 100644 (file)
@@ -124,9 +124,10 @@ mode:
 .IP \[bu] 4
 Encrypted files will not be extracted.
 .IP \[bu]
 .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
 .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
index d744268613f9db1ed08c357bc3dd3f84676d13e1..3f4a4562567ba223183636f2836fde07fb0bf660 100644 (file)
@@ -292,8 +292,10 @@ win32_start_extract(const wchar_t *path, struct apply_ctx *ctx)
 
        ctx->supported_features.not_context_indexed_files = 1;
 
 
        ctx->supported_features.not_context_indexed_files = 1;
 
+#if 0
        if (vol_flags & FILE_SUPPORTS_SPARSE_FILES)
                ctx->supported_features.sparse_files = 1;
        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;
 
        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;
 
        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;
        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,
 
        if (attributes & FILE_ATTRIBUTE_COMPRESSED)
                if (!DeviceIoControl(h, FSCTL_SET_COMPRESSION,