X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwimboot.c;h=cdd74d9468f267dece137673db408ec30a838068;hb=acb16926b00fabdba062ff4300da5d3aef32ceeb;hp=4d52acccd7f2334c11d0be80703304cc41d49d9d;hpb=bc38f3735bf6eaa2b856b1e05710b34bcfbbf787;p=wimlib diff --git a/src/wimboot.c b/src/wimboot.c index 4d52accc..cdd74d94 100644 --- a/src/wimboot.c +++ b/src/wimboot.c @@ -610,8 +610,8 @@ retry: if (wimlib_print_errors) { print_byte_field((const u8 *)hdr, sizeof(struct WimOverlay_dat_header), - stderr); - fputc('\n', stderr); + wimlib_error_file); + fputc('\n', wimlib_error_file); } ret = WIMLIB_ERR_UNSUPPORTED; goto out_free_contents; @@ -681,8 +681,9 @@ retry: path, i, entry_1->data_source_id); if (wimlib_print_errors) { print_byte_field((const u8 *)entry_2->wim_file_name, - wim_file_name_length, stderr); - fputc('\n', stderr); + wim_file_name_length, + wimlib_error_file); + fputc('\n', wimlib_error_file); } ret = WIMLIB_ERR_UNSUPPORTED; goto out_free_contents; @@ -719,8 +720,8 @@ retry: if (wimlib_print_errors) { print_byte_field((const u8 *)entry_2, entry_1->entry_2_length, - stderr); - fputc('\n', stderr); + wimlib_error_file); + fputc('\n', wimlib_error_file); } ret = WIMLIB_ERR_UNSUPPORTED; goto out_free_contents; @@ -806,6 +807,7 @@ update_wimoverlay_manually(const wchar_t *drive, const wchar_t *wim_path, if (ret) { ERROR_WITH_ERRNO("Can't rename \"%ls\" => \"%ls\"", path_main, path_wimlib_backup); + ret = WIMLIB_ERR_RENAME; goto out_free_new_contents; } } @@ -815,6 +817,7 @@ update_wimoverlay_manually(const wchar_t *drive, const wchar_t *wim_path, if (ret) { ERROR_WITH_ERRNO("Can't rename \"%ls\" => \"%ls\"", path_new, path_main); + ret = WIMLIB_ERR_RENAME; } out_free_new_contents: FREE(new_contents); @@ -828,26 +831,6 @@ out: return ret; } -static int -win32_get_drive_path(const wchar_t *file_path, wchar_t drive_path[7]) -{ - tchar *file_abspath; - - file_abspath = realpath(file_path, NULL); - if (!file_abspath) - return WIMLIB_ERR_NOMEM; - - if (file_abspath[0] == L'\0' || file_abspath[1] != L':') { - ERROR("\"%ls\": Path format not recognized", file_abspath); - FREE(file_abspath); - return WIMLIB_ERR_UNSUPPORTED; - } - - wsprintf(drive_path, L"\\\\.\\%lc:", file_abspath[0]); - FREE(file_abspath); - return 0; -} - /* Try to attach an instance of the Windows Overlay File System Filter Driver to * the specified drive (such as C:) */ static bool @@ -1041,10 +1024,10 @@ out: * This turns it into a reparse point that redirects accesses to it, to the * corresponding resource in the WIM archive. * - * @attr - * Object attributes that specify the path to the file. + * @h + * Open handle to the file, with GENERIC_WRITE access. * @printable_name - * Printable representation of the path encoded in @attr. + * Printable representation of the path to the file. * @lte * Unnamed data stream of the file. * @data_source_id @@ -1058,30 +1041,16 @@ out: * Returns 0 on success, or a positive error code on failure. */ int -wimboot_set_pointer(OBJECT_ATTRIBUTES *attr, +wimboot_set_pointer(HANDLE h, const wchar_t *printable_name, const struct wim_lookup_table_entry *lte, u64 data_source_id, const u8 lookup_table_hash[SHA1_HASH_SIZE], bool wof_running) { - int ret; - HANDLE h = NULL; - NTSTATUS status; - IO_STATUS_BLOCK iosb; DWORD bytes_returned; DWORD err; - status = (*func_NtOpenFile)(&h, GENERIC_WRITE | SYNCHRONIZE, attr, - &iosb, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT | - FILE_OPEN_REPARSE_POINT | - FILE_SYNCHRONOUS_IO_NONALERT); - if (!NT_SUCCESS(status)) { - SetLastError((*func_RtlNtStatusToDosError)(status)); - goto fail; - } - if (wof_running) { /* The WOF driver is running. We can create the reparse point * using FSCTL_SET_EXTERNAL_BACKING. */ @@ -1161,20 +1130,14 @@ wimboot_set_pointer(OBJECT_ATTRIBUTES *attr, goto fail; } - ret = 0; - goto out; + return 0; fail: err = GetLastError(); set_errno_from_win32_error(err); ERROR_WITH_ERRNO("\"%ls\": Couldn't set WIMBoot pointer data " "(err=%"PRIu32")", printable_name, (u32)err); - ret = WIMLIB_ERR_WIMBOOT; -out: - if (h) - (*func_NtClose)(h); - return ret; - + return WIMLIB_ERR_WIMBOOT; } #endif /* __WIN32__ */