[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mutt-dev
Subject:    PATH_MAX and POSIX (was: snprintf() results may get truncated)
From:       Eike Rathke <list () erack ! de>
Date:       2017-09-21 18:08:27
Message-ID: 20170921180827.GA31939 () kulungile ! erack ! de
[Download RAW message or body]


Hi Vincent,

On Tuesday, 2017-09-19 12:18:34 +0200, Vincent Lefevre wrote:

> Now, I don't see much point in defining both _POSIX_PATH_MAX and
> PATH_MAX for similar meanings. POSIX is strange, sometimes. :)

Might be ;-) but in this case the important difference is

_POSIX_PATH_MAX
Minimum number the implementation will accept as the maximum number of
bytes in a pathname.

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

So an implementation must accept at least and may accept more than
_POSIX_PATH_MAX bytes in a path name, but it must not store more than
PATH_MAX bytes in a user-supplied buffer.

That POSIX for PATH_MAX *also* says "Minimum number the implementation
will accept as the maximum number of bytes in a pathname." may be
confusing on first sight, but note that PATH_MAX is listed under
"Pathname Variable Values", where "variable" is to be taken seriously.
Those values can be queried using pathconf() and fpathconf() and may
depend on the underlying file system. For example,

    pathconf("/foo/bar", _PC_PATH_MAX)

queries the value for PATH_MAX in the context of /foo/bar

If a POSIX compliant implementation does not define a constant for one
of these variable values it means you *have* to query the correct value
from pathconf().

  Eike

-- 
OpenPGP/GnuPG encrypted mail preferred in all private communication.
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
Care about Free Software, support the FSFE https://fsfe.org/support/?erack
Use LibreOffice! https://www.libreoffice.org/

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic