From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19099 invoked by alias); 15 Nov 2010 19:27:35 -0000 Received: (qmail 18956 invoked by uid 22791); 15 Nov 2010 19:26:51 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.83/v0.83-20-g38e4449) with ESMTP; Mon, 15 Nov 2010 19:26:12 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id C32006D4272; Mon, 15 Nov 2010 20:26:09 +0100 (CET) Date: Mon, 15 Nov 2010 19:27:00 -0000 From: Corinna Vinschen To: cygwin-talk@cygwin.com Subject: Re: Cygwin mentioned in "current directory" discussion Message-ID: <20101115192609.GA22462@calimero.vinschen.de> Reply-To: cygwin-talk@cygwin.com Mail-Followup-To: cygwin-talk@cygwin.com References: <20101110043738.GA19327@ednor.casa.cgf.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20101110043738.GA19327@ednor.casa.cgf.cx> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-talk-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-talk-owner@cygwin.com Reply-To: The Vulgar and Unprofessional Cygwin-Talk List Mail-Followup-To: cygwin-talk@cygwin.com X-SW-Source: 2010-q4/txt/msg00020.txt.bz2 On Nov 9 23:37, Christopher Faylor wrote: > https://blogs.msdn.com/b/oldnewthing/archive/2010/11/09/10087919.aspx This morning I added a comment to the blog, #42 in the list: --- SNIP --- [I wouldn't put it past the Cygwin guys to patch ntdll...-Joshua] That's a bit over the top, but the new, undocumented way Vista and later uses to set the CWD requires some serious hacking to get the Linux semantics right. Note that the problem is not that SetCurrentDirectory creates a directory handle. The problem is that it creates a directory handle without the chance to set certain flags, analogous to the CreateFile call: - SetCurrentDirectory always opens dirs without the FILE_SHARE_DELETE flag. - SetCurrentDirectory always opens dirs without the FILE_FLAG_POSIX_SEMANTICS flag. - SetCurrentDirectory always opens dirs without the FILE_FLAG_BACKUP_SEMANTICS flag. Apart from that, an annoying problem of the SetCurrentDirectory call is it's quite obvious flaw to allow only paths of up to 258 chars, even the UNICODE variant. That's due to the fact that the CWD path storage is a fixed buffer of 260 wide chars (including a trailing backslash and a L'\0'). This is still true for the Vista/W7 style of CWD storage on the heap, even though the method would easily allow longer paths. A transparent solution for Windows 8 and later would be an Ex call as proposed by Andy, like this: BOOL SetCurrentDirectoryEx (LPCTSTR lpDirectoryName, DWORD dwShareMode, DWORD dwOpenFlags) with SetCurrentDirectoryExW allowing the same long pathname syntax for paths up to 32K as the CreateFileW and similar calls. Actually, for Cygwin it would already be sufficient (and even more convenient), to export the global pointer pointing to the current CWD datastructure on the heap. Or better, to export the function which returns this pointer. This would allow to get rid of the awkward code which extracts this global pointer by scanning the RtlGetCurrentDirectory_U function. I guess this should go without saying, but it would be nice if this new CWD storage method would be officially documented... --- SNAP --- Two minutes ago, I found that my comment had been silently removed! I'm not aware that my comment contained offensive, abusive, or disrespectful language. I'm really wondering why Raymond decided to remove my comment. This is quite disappointing. Corinna