summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r--winsup/cygwin/fhandler.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index a07bc85ab..6c745c097 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -370,6 +370,17 @@ fhandler_base::open (int flags, mode_t mode)
if (get_device () == FH_SERIAL)
file_attributes |= FILE_FLAG_OVERLAPPED;
+ /* CreateFile() with dwDesiredAccess == 0 when called on remote
+ share returns some handle, even if file doesn't exist. This code
+ works around this bug. */
+ if (get_query_open () &&
+ isremote () &&
+ creation_distribution == OPEN_EXISTING &&
+ GetFileAttributes (get_win32_name ()) == (DWORD) -1)
+ {
+ set_errno (ENOENT);
+ goto done;
+ }
x = CreateFileA (get_win32_name (), access, shared,
&sec_none, creation_distribution,
file_attributes,