From: Lasse Makholm Date: Mon, 21 Mar 2011 12:37:20 GMT Subject: Re: PATH_MAX (Re: [PATCH] system_path: use a static buffer) Message-ID: In-Reply-To: <1300700875.2583.8.camel@bee.lab.cmartin.tk> On 21 March 2011 10:47, Carlos Martín Nieto wrote: > On vie, 2011-03-18 at 06:38 -0500, Jonathan Nieder wrote: >> Hi, >> >> Nguyen Thai Ngoc Duy wrote: >> >> > It was pointed out elsewhere [1] that PATH_MAX only specifies max >> > length of a path element, not full path. I think we'd need to stay >> > away from preallocated PATH_MAX-sized arrays. >> >> No, PATH_MAX is actually the maximum length of a path, and when you >> use, say, open(2), it will fail if your path is longer than that.  The >> maximum length of a path component on most filesytems is 255 or 256; >> PATH_MAX on Linux is 4096. >> >> It is indeed possible to have paths with length longer than that.  The >> way to support that is to use relative paths wherever possible, which > >  So what PATH_MAX describes is the maximum length of a string > representing a path, but not necessarily the length of the path itself. According to this at least, PATH_MAX is bogus: http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html I think the sane thing would be to never rely on a fixed max path length. -- /Lasse