From 9c5469aa171f34e1af510a8a98ec056d27979bbf Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 28 Apr 2013 13:44:28 -0500 Subject: [PATCH 1/1] Win32: Fix cross-drive capture rpfix --- src/reparse.c | 13 +++++++++++++ src/win32.c | 12 +++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/reparse.c b/src/reparse.c index a245a7e1..4cbe69d9 100644 --- a/src/reparse.c +++ b/src/reparse.c @@ -465,6 +465,12 @@ capture_fixup_absolute_symlink(tchar *dest, { tchar *p = dest; +#ifdef __WIN32__ + /* Skip drive letter */ + if (!is_rp_path_separator(*dest)) + p += 2; +#endif + DEBUG("Fixing symlink or junction \"%"TS"\"", dest); for (;;) { tchar save; @@ -491,6 +497,13 @@ capture_fixup_absolute_symlink(tchar *dest, *(p - 1) = RP_PATH_SEPARATOR; while (p - 1 >= dest && is_rp_path_separator(*(p - 1))) p--; + #ifdef __WIN32__ + if (!is_rp_path_separator(dest[0])) { + *--p = dest[1]; + *--p = dest[0]; + } + #endif + wimlib_assert(p >= dest); return p; } diff --git a/src/win32.c b/src/win32.c index 36f33f52..f8efec04 100644 --- a/src/win32.c +++ b/src/win32.c @@ -678,6 +678,8 @@ win32_capture_maybe_rpfix_target(wchar_t *target, u16 *target_nbytes_p, if (ret < 0) return RP_NOT_FIXED; stripped_chars = ret; + if (stripped_chars) + stripped_chars -= 2; target[target_nchars] = L'\0'; orig_target = target; target = capture_fixup_absolute_symlink(target + stripped_chars, @@ -688,7 +690,7 @@ win32_capture_maybe_rpfix_target(wchar_t *target, u16 *target_nbytes_p, wmemmove(orig_target + stripped_chars, target, target_nchars + 1); *target_nbytes_p = (target_nchars + stripped_chars) * sizeof(wchar_t); DEBUG("Fixed reparse point (new target: \"%ls\")", orig_target); - if (stripped_chars == 6) + if (stripped_chars) return RP_FIXED_FULLPATH; else return RP_FIXED_ABSPATH; @@ -1314,6 +1316,14 @@ win32_build_dentry_tree(struct wim_dentry **root_ret, if (path_nchars > 32767) return WIMLIB_ERR_INVALID_PARAM; + if (GetFileAttributesW(root_disk_path) == INVALID_FILE_ATTRIBUTES && + GetLastError() == ERROR_FILE_NOT_FOUND) + { + ERROR("Capture directory \"%ls\" does not exist!", + root_disk_path); + return WIMLIB_ERR_OPENDIR; + } + ret = win32_get_file_and_vol_ids(root_disk_path, ¶ms->capture_root_ino, ¶ms->capture_root_dev); -- 2.43.0