summaryrefslogtreecommitdiff
path: root/hurd
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2021-04-28 10:43:57 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2021-04-28 10:43:57 +0200
commitf001583a040d9536074b3ad685bb57718df0f2af (patch)
tree681d164d06e3753ba03c1542ae37257d99f1fdf8 /hurd
parent79f9a4c9fbaf3f749f95619ace6730e9ff529735 (diff)
Add link to more explanation on PATH_MAX
Diffstat (limited to 'hurd')
-rw-r--r--hurd/porting/guidelines.mdwn2
1 files changed, 2 insertions, 0 deletions
diff --git a/hurd/porting/guidelines.mdwn b/hurd/porting/guidelines.mdwn
index 5986269e..d132f516 100644
--- a/hurd/porting/guidelines.mdwn
+++ b/hurd/porting/guidelines.mdwn
@@ -132,6 +132,8 @@ If you get Bad File Descriptor error when trying to read from a file (or accessi
<http://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html>
+Also see <https://eklitzke.org/path-max-is-tricky>
+
Every unconditionalized use of `PATH_MAX`, `MAX_PATH` or `MAXPATHLEN` is a POSIX incompatibility. If there is no upper limit on the length of a path (as its the case for GNU), this symbol is not defined in any header file. Instead, you need to either use a different implementation that does not rely on the length of a string or use `sysconf()` to query the length at runtime. If `sysconf()` returns -1, you have to use `realloc()` to allocate the needed memory dynamically. Usually it is thus simpler to just use dynamic allocation. Sometimes the amount is actually known. Else, a geometrically growing loop can be used: for instance, see [Pulseaudio patch](http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=patch-pulse;att=1;bug=522100). Note that in some cases there are GNU extensions that just work fine: when the `__GLIBC__` macro is defined, `getcwd()` calls can be just replaced by `get_current_dir_name()` calls.
Note: constants such as `_POSIX_PATH_MAX` are only the minimum required value