This is the mail archive of the cygwin 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: cant access to files more than 128 utf-8 symbol long names


On Dec 11 17:49, Mikhail Usenko wrote:
> On Tue, 10 Dec 2013 11:27:55 +0100
> Corinna Vinschen <...> wrote:
> 
> 
> > Easier said than done.
> > 
> > Cygwin is using the native NT API
> > and, occasionally, the Win32 UNICODE file API, which allows paths of up
> > to 32767 chars.
> > ...
> > How do you represent this in a byte-oriented POSIX system?  What do you
> > set NAME_MAX to?  You can't get it right due to the unfortunate multibyte
> > vs. UTF-16 encoding issue.
> > 
> > To cover all UTF-8 chars, NAME_MAX would have to be 1020.  But then,
> > applications relying on NAME_MAX will be surprised by ENAMETOOLONG
> > errors for perfectly valid POSIX filenames.
> > 
> > If you make it 255, applications will be surprised by ENAMETOOLONG
> > errors for perfectly valid Windows filenames.
> > 
> 
> Strictly speaking, the NAME_MAX and PATH_MAX POSIX' limits must be
> 32767*4 bytes, that is ~128K on Windows systems. With such a value no

Strictly speaking you're wrong.  NAME_MAX is the length of a single
path component, not the length of a path:

     NAME_MAX
       vvv
  /foo/bar/baz\0
  ^^^^^^^^^^^^^^
     PATH_MAX

Also, PATH_MAX is NOT the maximum length of a path, but the

  "Maximum number of bytes the implementation will store as a pathname
   in a user-supplied buffer of unspecified size, including the
   terminating null character."

That does not mean there are no longer paths possible, just that you
have to use, for instance, relative paths rather than absolute paths, if
the absolute path becomes longer than PATH_MAX, and that the system
does not guarantee to return paths if they are longer then PATH_MAX.


Corinna

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

Attachment: pgpLVXnsvgiT_.pgp
Description: PGP signature


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