OSDN Git Service

* fhandler.cc (fhandler_base::open): Work around windows bug when
authorduda <duda>
Wed, 20 Jun 2001 07:44:33 +0000 (07:44 +0000)
committerduda <duda>
Wed, 20 Jun 2001 07:44:33 +0000 (07:44 +0000)
CreateFile() with dwDesiredAccess == 0 called on remote share returns
valid handle even if file doesn't exist.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.cc

index 47a4c60..86341e0 100644 (file)
@@ -1,3 +1,9 @@
+2001-06-30  Egor Duda  <deo@logos-m.ru>
+
+       * fhandler.cc (fhandler_base::open): Work around windows bug when
+       CreateFile() with dwDesiredAccess == 0 called on remote share returns
+       valid handle even if file doesn't exist.
+
 2001-06-20  Egor Duda  <deo@logos-m.ru>
 
        * fhandler_socket.cc (fhandler_socket::signal_secret_event): New
index a07bc85..6c745c0 100644 (file)
@@ -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,