Date: Thu, 1 Mar 2001 15:05:04 -0600 From: "Jacques A. Vidrine" <n@nectar.com> To: Warner Losh <imp@harmony.village.org>, Garrett Wollman <wollman@khavrinen.lcs.mit.edu>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.bin/make arch.c main.c Message-ID: <20010301150504.A20983@hamlet.nectar.com> In-Reply-To: <20010301145142.A20573@hamlet.nectar.com>; from n@nectar.com on Thu, Mar 01, 2001 at 02:51:42PM -0600 References: <200103011743.MAA01724@khavrinen.lcs.mit.edu> <200103010603.f2163IM00616@freefall.freebsd.org> <200103011743.MAA01724@khavrinen.lcs.mit.edu> <200103011817.f21IHZd50132@harmony.village.org> <20010301145142.A20573@hamlet.nectar.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Mar 01, 2001 at 02:51:42PM -0600, Jacques A. Vidrine wrote: > On Thu, Mar 01, 2001 at 11:17:35AM -0700, Warner Losh wrote: > > In message <200103011743.MAA01724@khavrinen.lcs.mit.edu> Garrett Wollman writes: > > : <<On Wed, 28 Feb 2001 22:03:18 -0800 (PST), Warner Losh <imp@FreeBSD.org> said: > > : > > : > MAXPATHLEN includes the trailing NUL. > > : > > : Should have also changed the code to use PATH_MAX instead of > > : MAXPATHLEN. > > > > OK. Can you give me a pointer to the definition of PATH_MAX in a > > standards doc so I do it right? > > ISO/IEC 9945-1:1996 (POSIX.1) sections 2.8.2, 2.8.5, and tables 2.3, > 2.6 give us this: > > {_POSIX_PATH_MAX} ``The number of bytes in a pathname.'' Must be > defined as 255 in <limits.h>. We have this already. > > {PATH_MAX} ``Maximum number of bytes in a pathname (not a string > length; count excludes a terminating null).'' Must be at least > {_POSIX_PATH_MAX} if defined in <limits.h>. We have this already > (via syslimits.h). > > On some systems, {PATH_MAX} may not be defined in <limits.h>, in which > case you either have to assume {_POSIX_PATH_MAX} or use pathconf() to > find the ``real'' value. This is to support the case where the > maximum path length can vary from one filesystem to another, for example. > > Note that {PATH_MAX} _does not_ include a terminating null, and that > in sys/param.h we define MAXPATHLEN = PATH_MAX. A quick look through > the sources reveals lots & lots of `bugs' due to this. > > Hope this helps. I got the information above from my hardcopy of IEC/ISO 9945-1:1996/ IEEE Std 1003.1 1996. Then I thought it would be a good idea if I posted a link to an online version, so I surfed off to www.opengroup.org to get a link to SUSv2. http://www.opengroup.org/onlinepubs/007908799/xsh/limits.h.html I'll be damned if SUSv2 doesn't contradict ISO 9945-1: It says ``PATH_MAX Maximum number of bytes in a pathname, including the terminating null character.'' I think this is SUSv2 bug. Stevens writes in 1993 that PATH_MAX does not include room for a null character, and his program fragments in APUE consistently use PATH_MAX + 1. Cheers, -- Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010301150504.A20983>