[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SAGE] wither NAME_MAX?



On Mon Jan 20 10:20 2003 -0800, Hal Pomeranz wrote:
> I've recently been trying to compile a small C program on my Solaris 8
> system which uses the (I thought) standard NAME_MAX constant as the
> maximum number of chars in a file name (directory entry).  I'm including
> both limits.h and unistd.h but getting an undefined symbol error during
> compilation.  I'm using gcc v3.2.
> 
> Did I miss a memo from a POSIX committee or something?  Can somebody 
> provide insight on what's going on?  The same code compiles fine on
> other Unix systems I've tried.

The following comment appears in <limits.h> on my Solaris 8 box:

/*
 * POSIX 1003.1a, section 2.9.5, table 2-5 contains [NAME_MAX] and the
 * related text states:
 *
 * A definition of one of the values from Table 2-5 shall be omitted from the
 * <limits.h> on specific implementations where the corresponding value is
 * equal to or greater than the stated minimum, but where the value can vary
 * depending on the file to which it is applied. The actual value supported for
 * a specific pathname shall be provided by the pathconf() (5.7.1) function.
 *
 * This is clear that any machine supporting multiple file system types
 * and/or a network can not include this define, regardless of protection
 * by the _POSIX_SOURCE and _POSIX_C_SOURCE flags.
 *
 * #define      NAME_MAX        14
 */

Sounds like you might want to use the value from pathconf() instead.

Alternatively, if you want the maximum length of a full path name, and
not just the length of the basename, you can use PATH_MAX or
MAXPATHLEN.

-- 
Mark D. Roth <roth@feep.net>
http://www.feep.net/~roth/