Obtaining Size and Configuration Information

If you are writing applications for several UNIX platforms, it is wisest if your application can determine the size of certain platform-specific values. One frequently needed piece of information is the maximum length of a pathname. This is needed so that pathname buffers can be safely allocated.

The pathconf(2) and fpathconf(2) functions can answer your query about the size of a pathname buffer required. The function synopsis is as follows:

#include <unistd.h>

long pathconf(const char *path, int name);

long fpathconf(int fd, int name);

A number of configured values can be returned to the program with these functions. The tests that can be performed are summarized in Table 6.2.

Warning

When the ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.