]> wimlib.net Git - wimlib/blobdiff - src/wimboot.c
ntfs-3g_apply.c: Don't claim to support encrypted directories
[wimlib] / src / wimboot.c
index 6006bbe7f50c13b145dd732f5718ac2ad1c59593..2b6a2415181ec7c7d1b90d34798eecb6bf1038bc 100644 (file)
 #endif
 
 #include "wimlib/win32_common.h"
-#include "wimlib/win32.h"
+
 #include "wimlib/assert.h"
 #include "wimlib/error.h"
 #include "wimlib/lookup_table.h"
 #include "wimlib/util.h"
 #include "wimlib/wimboot.h"
+#include "wimlib/win32.h"
 #include "wimlib/wof.h"
 
 static HANDLE
@@ -1084,12 +1085,15 @@ wimboot_set_pointer(HANDLE h,
        if (wof_running) {
                /* The WOF driver is running.  We can create the reparse point
                 * using FSCTL_SET_EXTERNAL_BACKING.  */
-
+               unsigned int max_retries = 4;
                struct {
                        struct wof_external_info wof_info;
                        struct wim_provider_external_info wim_info;
                } in;
 
+       retry:
+               memset(&in, 0, sizeof(in));
+
                in.wof_info.version = WOF_CURRENT_VERSION;
                in.wof_info.provider = WOF_PROVIDER_WIM;
 
@@ -1103,7 +1107,22 @@ wimboot_set_pointer(HANDLE h,
                if (!DeviceIoControl(h, FSCTL_SET_EXTERNAL_BACKING,
                                     &in, sizeof(in), NULL, 0,
                                     &bytes_returned, NULL))
+               {
+                       /* Try to track down sporadic errors  */
+                       if (wimlib_print_errors) {
+                               WARNING("FSCTL_SET_EXTERNAL_BACKING failed (err=%u); data was %zu bytes:",
+                                       (u32)GetLastError(), sizeof(in));
+                               print_byte_field((const u8 *)&in, sizeof(in), wimlib_error_file);
+                               putc('\n', wimlib_error_file);
+                       }
+                       if (--max_retries) {
+                               WARNING("Retrying after 100ms...");
+                               Sleep(100);
+                               goto retry;
+                       }
+                       WARNING("Too many retries; returning failure");
                        return false;
+               }
        } else {
 
                /* The WOF driver is running.  We need to create the reparse