Re: PATH_MAX true POSIX size?

From: Heiner Steven (heiner.steven_at_nexgo.de)
Date: 01/29/05


Date: Sat, 29 Jan 2005 01:58:55 +0100

Heny Townsend wrote:
> I notice that PATH_MAX on Solaris is at (2**n - 1):
>
> % 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

> 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 <heiner.steven@nexgo.de>
\__ \  _/ -_) V / -_) ' \    Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_|   http://www.shelldorado.com/


Relevant Pages

  • Re: cvs commit: src/usr.sbin/sysinstall main.c
    ... If it wasn't obvious from my post, I think that the POSIX putenvis ... most of the software in ports probably runs more often on Linux than ... :> Solaris (judging by Open Solaris's putenv() implementation). ... This breaks Linux and Solaris and POSIX as well. ...
    (freebsd-arch)
  • Re: cvs commit: src/usr.sbin/sysinstall main.c
    ... If it wasn't obvious from my post, I think that the POSIX putenvis ... most of the software in ports probably runs more often on Linux than ... :> Solaris (judging by Open Solaris's putenv() implementation). ... This breaks Linux and Solaris and POSIX as well. ...
    (freebsd-arch)
  • Re: cvs commit: src/usr.sbin/sysinstall main.c
    ... most of the software in ports probably runs more often on Linux than ... :> Solaris (judging by Open Solaris's putenv() implementation). ... This breaks Linux and Solaris and POSIX as well. ...
    (freebsd-arch)
  • Re: PATH_MAX true POSIX size?
    ... I tried this with Solaris 8, and could not verify your results: ... Did somebody read POSIX wrong? ... Maximum number of bytes in a pathname, including the terminating ... Solaris 2.8 and Linux both get this right. ...
    (comp.unix.programmer)
  • Re: "Torn between two OS" - Solaris vs Linux
    ... POSIX 1996, except for legacy code. ... POSIX 2001 standards, incompatibilities and all, then Solaris is ... C99 like a hole in the head, or wants more compatibility with other ... systems, then Linux has it. ...
    (comp.os.linux.misc)