Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!cs.utexas.edu!uunet!uunet.UU.NET!sef From: lewine@cheshirecat.webo.dg.com (Donald Lewine) Newsgroups: comp.std.unix Subject: Re: FILENAME_MAX & _POSIX_PATH_MAX relationship? Message-ID: <129469@uunet.UU.NET> Date: 18 Apr 91 14:05:11 GMT References: <128112@uunet.UU.NET> <128358@uunet.UU.NET> <129356@uunet.UU.NET> <129356@uunet.UU.NET>, Sender: usenet@uunet.UU.NET Reply-To: lewine@dg.uucp Organization: Data General Corporation Lines: 52 Approved: sef@uunet.uu.net (Moderator, Sean Eric Fagan - comp.std.unix) Nntp-Posting-Host: uunet.uu.net X-Submissions: std-unix@uunet.uu.net Originator: sef@uunet.UU.NET Submitted-by: lewine@cheshirecat.webo.dg.com (Donald Lewine) In article <129356@uunet.UU.NET>, karish@mindcraft.com (Chuck Karish) writes: |> The C committee was trying to make it possible to write portable |> programs, not to constrain what must be present on your system. |> They were doomed to failure in an environment as complex as POSIX. |> That's why we have pathconf(). It's still reasonable to let the |> programmer know whether it's necessary to provide 13 characters |> or 256 or 1024 to hold a filename. |> Yes, it is very reasonable to let the programmer know whether it is necessary to 13 or 1024 characters to hold a pathname. Alas, POSIX does not do it! The symbols PATH_MAX and the values returned by pathconf() are pretty useless. The standard says that PATH_MAX is "Maximum number of bytes in a pathname" (Table 2-5). That statement is misleading, if not a complete lie. PATH_MAX is the longest pathname an application is guaranteed to be able to create. Most applications do not care about the longest pathname the are guaranteed to be able to create. They need to know the longest pathname that will be encoundered. In other words, how much storage should be allocated for the user's response to a "File: " prompt. Or, how large should the buffer be for getcwd(). Or, what is the longest path a file tree walk will encounter. _POSIX_PATH_MAX, PATH_MAX and pathconf() do not give any insight into those questions. Since most systems define PATH_MAX to be a large number, applications that use PATH_MAX to allocate buffers for getcwd() or user-supplied pathnames tend to work. The standard does not guarantee that they will work. In fact, even in their intended role, these symbols are not much use. I can always try to open() a file and see what error code comes back. In short, the only practical value is _POSIX_PATH_MAX is to force implementers to allow 256 character pathnames on all systems. It has no value to application programmers. -------------------------------------------------------------------- Donald A. Lewine (508) 870-9008 Voice Data General Corporation (508) 366-0750 FAX 4400 Computer Drive. MS D112A Westboro, MA 01580 U.S.A. uucp: uunet!dg!lewine Internet: lewine@cheshirecat.webo.dg.com Volume-Number: Volume 23, Number 34