delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/07/15/10:43:22

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Wed, 15 Jul 2009 16:42:56 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: [1.7] bug in chdir
Message-ID: <20090715144256.GB31834@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <loom DOT 20090714T213944-461 AT post DOT gmane DOT org> <20090715084635 DOT GQ27613 AT calimero DOT vinschen DOT de> <4A5DCFA7 DOT 9020106 AT byu DOT net> <20090715133117 DOT GA25645 AT calimero DOT vinschen DOT de> <loom DOT 20090715T134656-347 AT post DOT gmane DOT org>
MIME-Version: 1.0
In-Reply-To: <loom.20090715T134656-347@post.gmane.org>
User-Agent: Mutt/1.5.19 (2009-02-20)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019