FILENAME_MAX & _POSIX_PATH_MAX relationship?

David A Willcox willcox at urbana.mcd.mot.com
Tue Apr 9 00:18:15 AEST 1991


Submitted-by: willcox at urbana.mcd.mot.com (David A Willcox)

>Would someone who knows please tell me the relationship between the
>Standard C macro FILENAME_MAX and the POSIX macro _POSIX_PATH_MAX.

Since FILENAME_MAX is the longest possible filename string that can be
passed to fopen() and the like, it should be a value no smaller than
the largest possible value for PATH_MAX on your system.  It mustn't
ever be smaller than _POSIX_PATH_MAX, and would only be that small on
an implementation that only supported the minimum value for PATH_MAX
required by POSIX.

To quote from the C standard, FILENAME_MAX:

    ... expands to an integral constant expression that is the size needed
    for an array of char large enough to hold the longest file name
    string that the implementation guarantees can be opened. [There's
    a footnote saying that this doesn't mean that just any string this
    long is a valid file name.]

Since the C standard does not have any concept of directories, "file
name" in this context clearly corresponds to a POSIX path, not an
individual file name.

(Standard disclaimer stuff.  Motorola and POSIX disavow all knowledge of
my actions.)

David A. Willcox		"Just say 'NO' to universal drug testing"
Motorola MCD - Urbana		UUCP: ...!uiucuxc!udc!willcox
1101 E. University Ave.		INET: willcox at urbana.mcd.mot.com
Urbana, IL 61801		FONE: 217-384-8534


Volume-Number: Volume 23, Number 25



More information about the Comp.std.unix mailing list