Next: , Previous: File Minimums, Up: System Configuration   [Contents][Index]


32.9 Using pathconf

When your machine allows different files to have different values for a file system parameter, you can use the functions in this section to find out the value that applies to any particular file.

These functions and the associated constants for the parameter argument are declared in the header file unistd.h.

Function: long int pathconf (const char *filename, int parameter)

Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock fd mem | See POSIX Safety Concepts.

This function is used to inquire about the limits that apply to the file named filename.

The parameter argument should be one of the ‘_PC_’ constants listed below.

The normal return value from pathconf is the value you requested. A value of -1 is returned both if the implementation does not impose a limit, and in case of an error. In the former case, errno is not set, while in the latter case, errno is set to indicate the cause of the problem. So the only way to use this function robustly is to store 0 into errno just before calling it.

Besides the usual file name errors (see File Name Errors), the following error condition is defined for this function:

EINVAL

The value of parameter is invalid, or the implementation doesn’t support the parameter for the specific file.

Function: long int fpathconf (int filedes, int parameter)

Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock fd mem | See POSIX Safety Concepts.

This is just like pathconf except that an open file descriptor is used to specify the file for which information is requested, instead of a file name.

The following errno error conditions are defined for this function:

EBADF

The filedes argument is not a valid file descriptor.

EINVAL

The value of parameter is invalid, or the implementation doesn’t support the parameter for the specific file.

Here are the symbolic constants that you can use as the parameter argument to pathconf and fpathconf. The values are all integer constants.

_PC_LINK_MAX

Inquire about the value of LINK_MAX.

_PC_MAX_CANON

Inquire about the value of MAX_CANON.

_PC_MAX_INPUT

Inquire about the value of MAX_INPUT.

_PC_NAME_MAX

Inquire about the value of NAME_MAX.

_PC_PATH_MAX

Inquire about the value of PATH_MAX.

_PC_PIPE_BUF

Inquire about the value of PIPE_BUF.

_PC_CHOWN_RESTRICTED

Inquire about the value of _POSIX_CHOWN_RESTRICTED.

_PC_NO_TRUNC

Inquire about the value of _POSIX_NO_TRUNC.

_PC_VDISABLE

Inquire about the value of _POSIX_VDISABLE.

_PC_SYNC_IO

Inquire about the value of _POSIX_SYNC_IO.

_PC_ASYNC_IO

Inquire about the value of _POSIX_ASYNC_IO.

_PC_PRIO_IO

Inquire about the value of _POSIX_PRIO_IO.

_PC_FILESIZEBITS

Inquire about the availability of large files on the filesystem.

_PC_REC_INCR_XFER_SIZE

Inquire about the value of POSIX_REC_INCR_XFER_SIZE.

_PC_REC_MAX_XFER_SIZE

Inquire about the value of POSIX_REC_MAX_XFER_SIZE.

_PC_REC_MIN_XFER_SIZE

Inquire about the value of POSIX_REC_MIN_XFER_SIZE.

_PC_REC_XFER_ALIGN

Inquire about the value of POSIX_REC_XFER_ALIGN.

Portability Note: On some systems, the GNU C Library does not enforce _PC_NAME_MAX or _PC_PATH_MAX limits.


Next: , Previous: File Minimums, Up: System Configuration   [Contents][Index]