Re: PATH_MAX (Re: [PATCH] system_path: use a static buffer)
- From
Lasse Makholm <lasse.makholm@gmail.com>
- Date
- Mar 21, 2011, 12:37 UTC
- Message-ID
- <AANLkTinh4K0Crhs39wuZpKhmxcZkSGhKdZNarmHoimoH@mail.gmail.com>
- In-Reply-To
- <1300700875.2583.8.camel@bee.lab.cmartin.tk>
On 21 March 2011 10:47, Carlos Martín Nieto <cmn@elego.de> wrote:
Show 19 quoted lines
> 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