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 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: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-02-20) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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 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