From 5cdef6bbf584ca679dbf43fbdaea4a3f7cfe9933 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 2 Nov 2015 23:30:01 -0600 Subject: [PATCH] win32_apply.c: wait for FSCTL_SET_COMPRESSION to complete --- src/win32_apply.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/win32_apply.c b/src/win32_apply.c index 9ed563bb..c31d2668 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -1099,6 +1099,7 @@ adjust_compression_attribute(HANDLE h, const struct wim_dentry *dentry, FILE_BASIC_INFORMATION info; NTSTATUS status; USHORT compression_state; + DWORD bytes_returned; /* Get current attributes */ status = (*func_NtQueryInformationFile)(h, &ctx->iosb, @@ -1118,20 +1119,14 @@ adjust_compression_attribute(HANDLE h, const struct wim_dentry *dentry, else compression_state = COMPRESSION_FORMAT_NONE; - status = (*func_NtFsControlFile)(h, - NULL, - NULL, - NULL, - &ctx->iosb, - FSCTL_SET_COMPRESSION, - &compression_state, - sizeof(USHORT), - NULL, - 0); - if (NT_SUCCESS(status)) + /* Note: don't use NtFsControlFile() here unless prepared to handle + * STATUS_PENDING. */ + if (DeviceIoControl(h, FSCTL_SET_COMPRESSION, + &compression_state, sizeof(USHORT), NULL, 0, + &bytes_returned, NULL)) return 0; - winnt_error(status, L"Can't %s compression attribute on \"%ls\"", + win32_error(GetLastError(), L"Can't %s compression attribute on \"%ls\"", (compressed ? "set" : "clear"), current_path(ctx)); return WIMLIB_ERR_SET_ATTRIBUTES; } -- 2.43.0