This is the mail archive of the cygwin-talk mailing list for the cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin mentioned in "current directory" discussion


On 15 November 2010 19:26, Corinna Vinschen wrote:
> 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.

Perhaps it got swallowed by a COM server that can't deal with a
disappeared working directory. ;)

Andy


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]