tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: MAXPATHLEN vs PATH_MAX



On Sun, May 28, 2023 at 08:00:37AM +0200, tlaronde%polynum.com@localhost wrote:
 > Le Sat, May 27, 2023 at 08:50:21PM +0000, David Holland a ?crit :
 > > On Sat, May 27, 2023 at 09:10:34AM +0200, tlaronde%polynum.com@localhost wrote:
 > >  > Shouldn't be MAXPATHLEN be defined as PATH_MAX - 1?
 > > 
 > > No. They're the same. The existence of some old code where somebody
 > > didn't read the definition carefully (or that predates a clear
 > > definition) doesn't change that. Not sure why you think it should...
 > 
 > The comment in sys/param.h:
 > [snip]

...has been improved, thanks.

 > Shouldn't MAXPATHLEN be marked as deprecated precisely because of
 > the unfortunate ambiguity of its name, PATH_MAX being prefered in
 > it's stead, and the comment modified to clearly state it is a size
 > and not a length?

It is historic and not going anywhere; removing it would break a lot
of old code.

Also, I'm not sure everyone agrees with you on that distinction of
"size" and "length" (even though it makes a certain amount of sense)
so be careful about drawing too many conclusions.

Note that some of the length constants include null-terminator space
and some don't, with no particular pattern or logic other than
historical usage. E.g. MAXNAMLEN and its POSIX equivalent NAME_MAX are
511 and not 512 (historically, 255 rather than 256) because they
_don't_ include the space. For no particular reason.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index