summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2017-10-18 16:21:12 +0200
committerCorinna Vinschen <corinna@vinschen.de>2017-10-18 16:21:12 +0200
commite6c79e7a2ab7fe9e1d45c25526841e035ee67407 (patch)
tree2df8e808739cc35b97ef0929298ca1cd4168b325
parent3dda58f1573a7e216f4656a3248252aea4f30593 (diff)
downloadcygnal-e6c79e7a2ab7fe9e1d45c25526841e035ee67407.tar.gz
cygnal-e6c79e7a2ab7fe9e1d45c25526841e035ee67407.tar.bz2
cygnal-e6c79e7a2ab7fe9e1d45c25526841e035ee67407.zip
cygwin: unlink: fix "final trick" overwrite method on remote drives
The "final trick" code in try_to_bin accidentally never worked on remote drives because it relies on rootdir. Which isn't set for remote unlinks. The code now creates a full path for remote files. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/syscalls.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index e64b01797..8ccc7681e 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -542,8 +542,22 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags)
delete-on-close on the original file succeeds. There are still
cases in which this fails, for instance, when trying to delete a
hardlink to a DLL used by the unlinking application itself. */
- RtlAppendUnicodeToString (&recycler, L"X");
- InitializeObjectAttributes (&attr, &recycler, 0, rootdir, NULL);
+ if (pc.isremote ())
+ {
+ /* In the remote case we need the full path, but recycler is only
+ a relative path. Convert to absolute path. */
+ RtlInitEmptyUnicodeString (&fname, (PCWSTR) tp.w_get (),
+ (NT_MAX_PATH - 1) * sizeof (WCHAR));
+ RtlCopyUnicodeString (&fname, pc.get_nt_native_path ());
+ RtlSplitUnicodePath (&fname, &fname, NULL);
+ /* Reset max length, overwritten by RtlSplitUnicodePath. */
+ fname.MaximumLength = (NT_MAX_PATH - 1) * sizeof (WCHAR); /* reset */
+ RtlAppendUnicodeStringToString (&fname, &recycler);
+ }
+ else
+ fname = recycler;
+ RtlAppendUnicodeToString (&fname, L"X");
+ InitializeObjectAttributes (&attr, &fname, 0, rootdir, NULL);
status = NtCreateFile (&tmp_fh, DELETE, &attr, &io, NULL,
FILE_ATTRIBUTE_NORMAL, 0, FILE_SUPERSEDE,
FILE_NON_DIRECTORY_FILE | FILE_DELETE_ON_CLOSE,