[PATCH] Fix readdir_r with long file names

Roland McGrath roland@hack.frob.com
Tue Jun 11 17:42:00 GMT 2013


> On 06/11/2013 12:36 AM, Roland McGrath wrote:
> >> There's precedent for my approach in realpath, where we don't use
> >> pathconf(path, _PC_PATH_MAX), either, but cap the path length at PATH_MAX.
> >
> > That's just following vanilla POSIX.1 rules: if PATH_MAX is defined at
> > compile time, it's a fixed system-wide limit.  If PATH_MAX is not defined
> > at compile time, there might or might not be a limit and if there is a
> > limit it might be filesystem-specific; pathconf reports that.
> 
> We must continue to define PATH_MAX and NAME_MAX for backwards 
> compatibility reasons.  This leads to ugly kludges when we're confronted 
> with data from the kernel that exceeds the constants.  (getwd is another 
> such place.)

You cited the implementation details of canonicalize.c as an indication
that using PATH_MAX made some sort of intrinsic sense even if it might not
be the real limit.  I was pointing out that there was no such rationale
involved in the use there.  In fact, it was written that way to be right
for the GNU systems where PATH_MAX is not defined and there is no limit.



More information about the Libc-alpha mailing list