summaryrefslogtreecommitdiff
path: root/hurd/porting/guidelines.mdwn
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-07-19 20:05:00 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-07-19 20:05:00 +0200
commit786cc5604dbad7eeb8ee2dbabdd38e008d838720 (patch)
tree756b0b1ee84a184539d1b0bd71c50fc09ed9f166 /hurd/porting/guidelines.mdwn
parent695ec1231990c5ee327622975cec0cc1ecfe3192 (diff)
comment on _POSIX_PATH_MAX and realpath bogusness
Diffstat (limited to 'hurd/porting/guidelines.mdwn')
-rw-r--r--hurd/porting/guidelines.mdwn4
1 files changed, 4 insertions, 0 deletions
diff --git a/hurd/porting/guidelines.mdwn b/hurd/porting/guidelines.mdwn
index ade921b0..fc3f518f 100644
--- a/hurd/porting/guidelines.mdwn
+++ b/hurd/porting/guidelines.mdwn
@@ -54,6 +54,10 @@ If you get Bad File Descriptor error when trying to read from a file (or accessi
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 [Alioth patch](http://alioth.debian.org/tracker/download.php/30628/410472/303735/1575/cpulimit-path-max-fix.patch) or [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 for a potential corresponding PATH_MAX macro. They are not a replacement for PATH_MAX, just the minimum value that one can assume.
+
+Note2: Yes, some POSIX functions such as realpath() actually assume that PATH_MAX is defined. This is a bug of the POSIX standard, which got fixed in the latest revisions, in which one can simply pass NULL to get a dynamically allocated buffer.
+
## <a name="ARG_MAX"> `ARG_MAX` </a>
Same rationale as `PATH_MAX`. There is no limit on the number of arguments.