Cygwin mentioned in "current directory" discussion
Mon Nov 15 21:35:00 GMT 2010
On 15 November 2010 19:26, Corinna Vinschen wrote:
> On Nov 9 23:37, Christopher Faylor wrote:
> 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
> 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
> - 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.
Perhaps it got swallowed by a COM server that can't deal with a
disappeared working directory. ;)
More information about the Cygwin-talk