This is the mail archive of the cygwin-developers 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]

CWD and long paths


Hi,


as everybody is probably aware, NT can handle paths of up to 32K unicode
characters length within the NT namespace.  Many Win32 calls of the fooW
family (taking utf-16 strings) can handle these long pathnames as well(*).

The problem is, the SetCurrentDirectory function can *not* handle long
path names and, generally spoken, Win32 can *not* handle current working
directories of more than MAX_PATH (260) characters.  The reason for this
restriction is the fact that the per-process environment block (PEB),
which is handled by the Win32 libraries, stores the CWD in a structure
like this:

  struct cwd {
    WCHAR path[MAX_PATH];
    HANDLE hdl;
  }

The NT kernel itself has no notion of a current working directory,
rather it allows to define paths relative to a directory handle in all
calls taking path names.

In Cygwin we can do as we like, so we can handle CWDs with long path
names without problems.  Unfortunately we have to call non-Cygwin
applications once in a while and then it gets weird.

So, here's the question: How should we handle the CWD in future?

- We could stick to only supporting CWDs of MAX_PATH length so we don't
  have a problem when calling native apps.

- We could support long CWDs and change the CWD to the longest path
  prefix <= MAX_PATH as soon as we call a native app.

- Something else?


Corinna


(*) See http://msdn2.microsoft.com/en-us/library/aa365247.aspx(**)

(**) I have set PATH_MAX to 32760 in include/limits.h, while the
     aforementioned MSDN article carefully talks about 32000 chars
     path length.  Should we better do the same?


-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


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