public inbox for cygwin-talk@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-talk@cygwin.com
Subject: Re: Cygwin mentioned in "current directory" discussion
Date: Mon, 15 Nov 2010 19:27:00 -0000	[thread overview]
Message-ID: <20101115192609.GA22462@calimero.vinschen.de> (raw)
In-Reply-To: <20101110043738.GA19327@ednor.casa.cgf.cx>

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

  reply	other threads:[~2010-11-15 19:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-10  4:38 Christopher Faylor
2010-11-15 19:27 ` Corinna Vinschen [this message]
2010-11-15 21:35   ` Andy Koppe
2010-11-16  8:30     ` Corinna Vinschen
2010-11-16 16:11       ` Christopher Faylor
2010-11-16 19:54         ` Corinna Vinschen
2010-11-16 21:10           ` Christopher Faylor
2010-11-25  2:59           ` Dave Korn
2010-11-25  8:32             ` Corinna Vinschen
2010-11-27 11:20           ` Gary
2010-11-27 19:13             ` Christopher Faylor
2010-11-30  9:37               ` Gary

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101115192609.GA22462@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-talk@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).