FILENAME_MAX & _POSIX_PATH_MAX relationship?
Donald Lewine
lewine at cheshirecat.webo.dg.com
Fri Apr 19 00:05:11 AEST 1991
Submitted-by: lewine at cheshirecat.webo.dg.com (Donald Lewine)
In article <129356 at uunet.UU.NET>, karish at 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 at cheshirecat.webo.dg.com
Volume-Number: Volume 23, Number 34
More information about the Comp.std.unix
mailing list