From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21471 invoked by alias); 15 Nov 2010 21:35:36 -0000 Received: (qmail 21401 invoked by uid 22791); 15 Nov 2010 21:35:35 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-yw0-f43.google.com (HELO mail-yw0-f43.google.com) (209.85.213.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Nov 2010 21:34:49 +0000 Received: by ywk9 with SMTP id 9so3969392ywk.2 for ; Mon, 15 Nov 2010 13:34:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.151.146.10 with SMTP id y10mr10338460ybn.151.1289856887188; Mon, 15 Nov 2010 13:34:47 -0800 (PST) Received: by 10.150.144.13 with HTTP; Mon, 15 Nov 2010 13:34:47 -0800 (PST) In-Reply-To: <20101115192609.GA22462@calimero.vinschen.de> References: <20101110043738.GA19327@ednor.casa.cgf.cx> <20101115192609.GA22462@calimero.vinschen.de> Date: Mon, 15 Nov 2010 21:35:00 -0000 Message-ID: Subject: Re: Cygwin mentioned in "current directory" discussion From: Andy Koppe To: cygwin-talk@cygwin.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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/msg00021.txt.bz2 On 15 November 2010 19:26, Corinna Vinschen wrote: > On Nov =C2=A09 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 --- > =C2=A0[I wouldn't put it past the Cygwin guys to patch ntdll...-Joshua] > > =C2=A0That's a bit over the top, but the new, undocumented way Vista and = later > =C2=A0uses to set the CWD requires some serious hacking to get the Linux = semantics > =C2=A0right. > > =C2=A0Note that the problem is not that SetCurrentDirectory creates a > =C2=A0directory handle. =C2=A0The problem is that it creates a directory = handle > =C2=A0without the chance to set certain flags, analogous to the CreateFile > =C2=A0call: > > =C2=A0- SetCurrentDirectory always opens dirs without the FILE_SHARE_DELE= TE flag. > =C2=A0- SetCurrentDirectory always opens dirs without the FILE_FLAG_POSIX= _SEMANTICS flag. > =C2=A0- SetCurrentDirectory always opens dirs without the FILE_FLAG_BACKU= P_SEMANTICS flag. > > =C2=A0Apart from that, an annoying problem of the SetCurrentDirectory cal= l is > =C2=A0it's quite obvious flaw to allow only paths of up to 258 chars, eve= n the > =C2=A0UNICODE variant. =C2=A0That's due to the fact that the CWD path sto= rage is a > =C2=A0fixed buffer of 260 wide chars (including a trailing backslash and a > =C2=A0L'\0'). =C2=A0This is still true for the Vista/W7 style of CWD stor= age on the > =C2=A0heap, even though the method would easily allow longer paths. > > =C2=A0A transparent solution for Windows 8 and later would be an Ex call = as > =C2=A0proposed by Andy, like this: > > =C2=A0 =C2=A0BOOL SetCurrentDirectoryEx (LPCTSTR lpDirectoryName, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DWORD dwShareMode, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DWORD dwOpenFlags) > > =C2=A0with SetCurrentDirectoryExW allowing the same long pathname syntax = for > =C2=A0paths up to 32K as the CreateFileW and similar calls. > > =C2=A0Actually, for Cygwin it would already be sufficient (and even more > =C2=A0convenient), to export the global pointer pointing to the current C= WD > =C2=A0datastructure on the heap. =C2=A0Or better, to export the function = which > =C2=A0returns this pointer. =C2=A0This would allow to get rid of the awkw= ard code > =C2=A0which extracts this global pointer by scanning the > =C2=A0RtlGetCurrentDirectory_U function. > > =C2=A0I guess this should go without saying, but it would be nice if this= new > =C2=A0CWD 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. =C2=A0I'm really wondering why Raymond decided > to remove my comment. =C2=A0This is quite disappointing. Perhaps it got swallowed by a COM server that can't deal with a disappeared working directory. ;) Andy