Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-02-20 17:42:29 +0300
committerCorinna Vinschen <corinna@vinschen.de>2008-02-20 17:42:29 +0300
commit44464b015610d5da982bc58e5ccc4cfda38a9274 (patch)
treec58647dc04b30aee5d388b4fbb5ee9f88e75679f
parent6532abb624384b9c0429928e5a9f88a8d77009cf (diff)
* path.cc (cwdstuff::set): Revert error handling change in case
DuplicateHandle fails, because it breaks Vista/Longhorn workaround.
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/path.cc22
2 files changed, 14 insertions, 13 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c310ebb36..3cb2cfda4 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-20 Corinna Vinschen <corinna@vinschen.de>
+
+ * path.cc (cwdstuff::set): Revert error handling change in case
+ DuplicateHandle fails, because it breaks Vista/Longhorn workaround.
+
2008-02-19 Christopher Faylor <me+cygwin@cgf.cx>
* sigproc.cc (sig_send): Use sigmask of target thread if it is
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index b57a2ced8..39293602e 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -4429,7 +4429,7 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit)
- Unlinking a cwd fails because SetCurrentDirectory seems to
open directories so that deleting the directory is disallowed.
The below code opens with *all* sharing flags set. */
- HANDLE h, h_copy;
+ HANDLE h;
NTSTATUS status;
IO_STATUS_BLOCK io;
OBJECT_ATTRIBUTES attr;
@@ -4454,25 +4454,21 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit)
res = -1;
goto out;
}
- /* Workaround a problem in Vista which fails in subsequent calls to
- CreateFile with ERROR_INVALID_HANDLE if the handle in
+ /* Workaround a problem in Vista/Longhorn which fails in subsequent
+ calls to CreateFile with ERROR_INVALID_HANDLE if the handle in
CurrentDirectoryHandle changes without calling SetCurrentDirectory,
and the filename given to CreateFile is a relative path. It looks
like Vista stores a copy of the CWD handle in some other undocumented
place. The NtClose/DuplicateHandle reuses the original handle for
the copy of the new handle and the next CreateFile works.
Note that this is not thread-safe (yet?) */
- if (!DuplicateHandle (GetCurrentProcess (), h, GetCurrentProcess (),
- &h_copy, 0, TRUE, DUPLICATE_SAME_ACCESS))
- {
- RtlReleasePebLock ();
- __seterrno ();
- NtClose (h);
- res = -1;
- goto out;
- }
NtClose (*phdl);
- dir = *phdl = h;
+ if (DuplicateHandle (GetCurrentProcess (), h, GetCurrentProcess (), phdl,
+ 0, TRUE, DUPLICATE_SAME_ACCESS))
+ NtClose (h);
+ else
+ *phdl = h;
+ dir = *phdl;
/* No need to set path on init. */
if (nat_cwd