Discussion:
PATH_MAX true POSIX size?
(too old to reply)
Heny Townsend
2005-01-29 00:17:44 UTC
Permalink
I notice that PATH_MAX on Solaris is at (2**n - 1):

% getconf -a | grep PATH_MAX
PATH_MAX: 1023
_POSIX_PATH_MAX: 255

Whereas on Linux and FreeBSD it's the full round number (256/1024 on
FreeBSD, 256/4096 on Linux). Did somebody read POSIX wrong? Or is it a
case where POSIX is unclear and Sun decided to be pessimistic while the
freebies were optimistic? Or maybe Solaris is counting on the fact that
a request for 1023 bytes will generally be padded to 1024, thus allowing
a "hidden" spot for the null byte and avoiding programmer off-by-one errors?

Notice that it's not just the interpretation of PATH_MAX that differs.
They disagree on the interpretation of _POSIX_PATH_MAX too.
--
Henry Townsend
Heiner Steven
2005-01-29 00:58:55 UTC
Permalink
Post by Heny Townsend
% getconf -a | grep PATH_MAX
PATH_MAX: 1023
_POSIX_PATH_MAX: 255
I tried this with Solaris 8, and could not verify your results:

$ getconf -a | grep PATH_MAX
PATH_MAX: 1024
_POSIX_PATH_MAX: 255
Post by Heny Townsend
Whereas on Linux and FreeBSD it's the full round number (256/1024 on
FreeBSD, 256/4096 on Linux). Did somebody read POSIX wrong? Or is it a
case where POSIX is unclear and Sun decided to be pessimistic while the
freebies were optimistic? Or maybe Solaris is counting on the fact that
a request for 1023 bytes will generally be padded to 1024, thus allowing
a "hidden" spot for the null byte and avoiding programmer off-by-one errors?
Notice that it's not just the interpretation of PATH_MAX that differs.
They disagree on the interpretation of _POSIX_PATH_MAX too.
POSIX (at least IEEE Std 1003.1, 2004 Edition) is clear on this:

PATH_MAX
Maximum number of bytes in a pathname, including the terminating
null character. Minimum Acceptable Value: _POSIX_PATH_MAX
[...]

_POSIX_PATH_MAX
Maximum number of bytes in a pathname. Value: 256

So it seems that with Solaris 8 "getconf" prints PATH_MAX correctly,
but prints a wrong result for _POSIX_PATH_MAX .

Confusingly enough NAME_MAX (the length of a path component) does not
include the terminating null character:

NAME_MAX
Maximum number of bytes in a filename (not including terminating
null). Minimum Acceptable Value: _POSIX_NAME_MAX

_POSIX_NAME_MAX
Maximum number of bytes in a filename (not including terminating
null). Value: 14

Solaris 2.8 and (SuSE) Linux both get this right.

Heiner
--
___ _
/ __| |_ _____ _____ _ _ Heiner STEVEN <***@nexgo.de>
\__ \ _/ -_) V / -_) ' \ Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_| http://www.shelldorado.com/
Heny Townsend
2005-01-29 01:25:57 UTC
Permalink
Post by Heiner Steven
Post by Heny Townsend
% getconf -a | grep PATH_MAX
PATH_MAX: 1023
_POSIX_PATH_MAX: 255
$ getconf -a | grep PATH_MAX
PATH_MAX: 1024
_POSIX_PATH_MAX: 255
Interesting. My results are from Solaris 9 and are quite verifiable:

% uname -a
SunOS xxxxx 5.9 Generic_117171-13 sun4u sparc SUNW,Ultra-5_10
% getconf -a | grep PATH_MAX
PATH_MAX: 1023
_POSIX_PATH_MAX: 255

But hang on, let me fire up my beta of Solaris 10 from a few months ago ...

% getconf -a | grep PATH_MAX
PATH_MAX: 1024
_POSIX_PATH_MAX: 255
_XOPEN_PATH_MAX: 1024

Sheesh, they're all over the map on such a basic thing! And they still
don't know that POSIX says _POSIX_PATH_MAX *must* be 256? Someone from
Sun please restore my faith!
--
Henry Townsend
Richard B. Gilbert
2005-01-29 02:46:47 UTC
Permalink
Post by Heny Townsend
Post by Heiner Steven
Post by Heny Townsend
% getconf -a | grep PATH_MAX
PATH_MAX: 1023
_POSIX_PATH_MAX: 255
$ getconf -a | grep PATH_MAX
PATH_MAX: 1024
_POSIX_PATH_MAX: 255
% uname -a
SunOS xxxxx 5.9 Generic_117171-13 sun4u sparc SUNW,Ultra-5_10
% getconf -a | grep PATH_MAX
PATH_MAX: 1023
_POSIX_PATH_MAX: 255
But hang on, let me fire up my beta of Solaris 10 from a few months ago ...
% getconf -a | grep PATH_MAX
PATH_MAX: 1024
_POSIX_PATH_MAX: 255
_XOPEN_PATH_MAX: 1024
Sheesh, they're all over the map on such a basic thing! And they still
don't know that POSIX says _POSIX_PATH_MAX *must* be 256? Someone from
Sun please restore my faith!
sunburn_$ uname -a
SunOS sunburn 5.9 Generic sun4u sparc SUNW,Ultra-5_10
sunburn_$ getconf -a | grep PATH_MAX
PATH_MAX: 1024
_POSIX_PATH_MAX: 255

I upgraded Sunburn from Solaris 8 a few months ago.

sunblok_$ uname -a
SunOS sunblok 5.8 Generic_117350-12 sun4u sparc SUNW,Ultra-5_10
sunblok_$ getconf -a | grep PATH_MAX
_POSIX_PATH_MAX: 255
PATH_MAX: 1024
Alex Zarutin
2005-01-30 02:03:46 UTC
Permalink
bash-2.05$ uname -a
SunOS qadmz41 5.9 Generic_117171-08 sun4u sparc SUNW,Sun-Fire-V240
bash-2.05$ getconf -a | grep PATH_MAX
PATH_MAX: 1024
_POSIX_PATH_MAX: 255
bash-2.05$
Geoff Clare
2005-01-31 14:14:15 UTC
Permalink
Post by Heny Townsend
Sheesh, they're all over the map on such a basic thing! And they still
don't know that POSIX says _POSIX_PATH_MAX *must* be 256?
The cause of the confusion was POSIX itself. Up until the 2001 revision
it was unclear whether PATH_MAX included the null terminator or not,
and _POSIX_PATH_MAX was required to be 255. In the 2001 revision the
confusion was fixed by requiring PATH_MAX to include the null, and
_POSIX_PATH_MAX was changed to 256 to match.
--
Geoff Clare <***@gclare.org.uk>
Joerg Schilling
2005-01-31 15:40:35 UTC
Permalink
Post by Geoff Clare
Post by Heny Townsend
Sheesh, they're all over the map on such a basic thing! And they still
don't know that POSIX says _POSIX_PATH_MAX *must* be 256?
The cause of the confusion was POSIX itself. Up until the 2001 revision
it was unclear whether PATH_MAX included the null terminator or not,
and _POSIX_PATH_MAX was required to be 255. In the 2001 revision the
confusion was fixed by requiring PATH_MAX to include the null, and
_POSIX_PATH_MAX was changed to 256 to match.
Which is even honored by Solaris 10 (the first POSIX.1-2001 Solaris system).
It depenfs on XGP6 to return 256 instead of 255.
--
EMail:***@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
***@cs.tu-berlin.de (uni)
***@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
URL: http://www.fokus.fraunhofer.de/usr/schilling ftp://ftp.berlios.de/pub/schily
Casper H.S. Dik
2005-01-31 13:38:44 UTC
Permalink
Post by Heny Townsend
% getconf -a | grep PATH_MAX
PATH_MAX: 1023
_POSIX_PATH_MAX: 255
I get:

/bin/getconf -a | grep PATH_MAX
PATH_MAX: 1024
_POSIX_PATH_MAX: 255

on everything from Solaris 7 to 10. (may not have checked 8).

What are you running, which shell?

Note that both numbers are correct; PATH_MAX/1024 is the path buffer size and
_POSIX_PATH_MAX is the minimal acceptable value. It is defined in
XPG4 and before as 255; only XPG6 defines it asa 256.
Post by Heny Townsend
Whereas on Linux and FreeBSD it's the full round number (256/1024 on
FreeBSD, 256/4096 on Linux). Did somebody read POSIX wrong? Or is it a
case where POSIX is unclear and Sun decided to be pessimistic while the
freebies were optimistic? Or maybe Solaris is counting on the fact that
a request for 1023 bytes will generally be padded to 1024, thus allowing
a "hidden" spot for the null byte and avoiding programmer off-by-one errors?
Notice that it's not just the interpretation of PATH_MAX that differs.
They disagree on the interpretation of _POSIX_PATH_MAX too.
255 for _POSIX_PATH_MAX is right for all environments except XPG6+.

Where did you get the PATH_MAX = 1023 output from? I can't reproduce
it anywhere.

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Heny Townsend
2005-01-31 14:41:53 UTC
Permalink
Post by Casper H.S. Dik
Post by Heny Townsend
% getconf -a | grep PATH_MAX
PATH_MAX: 1023
_POSIX_PATH_MAX: 255
/bin/getconf -a | grep PATH_MAX
PATH_MAX: 1024
_POSIX_PATH_MAX: 255
on everything from Solaris 7 to 10. (may not have checked 8).
What are you running, which shell?
I brought up a new shell to verify my previous results and instead got
the same as you. For a few minutes I thought I was going crazy because
the previous 1023 value was cut and pasted on the exact same machine.
But then I figured it out. I have ClearCase installed here. In normal
UFS space getconf returns 1024 while in MVFS space it shows 1023.

So apparently the 255/256 difference is explained by evolution of
standards, while the 1023/1024 difference is something the makers of
ClearCase would be best equipped to explain. Sorry for the FUD.
--
Henry Townsend
Loading...