This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [1.7] bug in chdir


On Jul 15 13:58, Eric Blake wrote:
> Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:
> >   The fact that accessing //home does not create an
> > exception points to a successful SMB name resolution.
> [...]
>   It still seems like chdir() should do some 
> sort of stat() test rather than just a successful SMB name resolution when 
> attempting to change to //name.

That's not that easy.  Since there's no real path //server supported in
Windows Cygwin has to rely on WNetGetResourceInformation for the
existence check and if the existence is confirmed, it allows to open a
file descriptor to this virtual path.

I created a patch which uses WNetOpenEnum for the existence check, but
it needs extremly long to timeout the existence check in such a case.

I assume you're set up to build your own Cygwin DLL, so you may try the
below patch.  I'm not yet convinced it's a good thing to apply it,
though.  It potentially slows down net operation a lot for the sake of a
rare border case.  Frying pan, Fire.  Anyway, please give it a try.

Index: fhandler_netdrive.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_netdrive.cc,v
retrieving revision 1.24
diff -u -p -r1.24 fhandler_netdrive.cc
--- fhandler_netdrive.cc	15 Jul 2009 14:31:51 -0000	1.24
+++ fhandler_netdrive.cc	15 Jul 2009 14:40:58 -0000
@@ -164,15 +164,20 @@ fhandler_netdrive::exists ()
     *to = (*from == '/') ? '\\' : *from;
   *to = '\0';
 
+  struct net_hdls nh =  { NULL, NULL };
   NETRESOURCE nr = {0};
-  nr.dwScope = RESOURCE_GLOBALNET;
   nr.dwType = RESOURCETYPE_DISK;
-  nr.lpLocalName = NULL;
   nr.lpRemoteName = namebuf;
-  DWORD ret = create_thread_and_wait (GET_RESOURCE_INFO, &nr, NULL, 0,
-				      "WNetGetResourceInformation");
-  if (ret != ERROR_MORE_DATA && ret != NO_ERROR)
-    return 0;
+  DWORD ret = create_thread_and_wait (GET_RESOURCE_OPENENUM,
+				      &nr, &nh, 0, "WNetOpenEnum");
+  if (ret != NO_ERROR)
+    {
+      if (nh.dom)
+	WNetCloseEnum (nh.dom);
+      if (nh.net)
+	WNetCloseEnum (nh.net);
+      return 0;
+    }
   return 1;
 }
 

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]