[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PATH_MAX constant expression
From: |
Bruno Haible |
Subject: |
Re: PATH_MAX constant expression |
Date: |
Fri, 24 Jun 2011 02:44:35 +0200 |
User-agent: |
KMail/1.9.9 |
Hi Jim,
> Bruno's comment (in the text you elided) suggests intent to have
> pathmax.h leave PATH_MAX undefined on the Hurd:
>
> >> I find it reasonable to use "#ifdef PATH_MAX" in front of every use of
> >> PATH_MAX, like POSIX requires.
>
> With such a change, each of the above uses would evoke a syntax error.
A package like coreutils can also do
#ifndef PATH_MAX
# define PATH_MAX 8192
#endif
in its system.h.
Looking at both uses of PATH_MAX in coreutils (src/pwd.c:88 and
src/remove.c:186) the value of PATH_MAX is capped by 8192 or 16384 anyway.
So, on systems like GNU/Hurd, where filenames can have arbitrary size, you
are calling pathconf for no real purpose.
To me, this confirms that a generic pathmax.h (like the one in gnulib)
should only define PATH_MAX when it makes sense - like POSIX says -,
and that the handling of the GNU/Hurd case should be done on a case-by-case
basis:
- Either a package-wide handling, or a per-file handling.
- Either a fallback value of 8192, or a fallback value of
pathconf ("/", _PC_PATH_MAX), or just a #ifdef test.
Bruno