Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

pathconf, fpathconf - get value of pathname variable

&pagelevel(4)&pagelevel

Syntax

#include <unistd.h>

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

Description

pathconf() and fpathconf() provide a method of determining the current value of a configurable system variable name that is associated with a file or directory.

For pathconf(), path points to the pathname of a file or directory.

For fpathconf(), fildes is an open file descriptor.

The C runtime system supports the variables listed in the following table. Other X/Open conformant implementations may support additional variables. The table below contains the system variables from the headers limits.h or unistd.h that can be queried with pathconf() or fpathconf(); the symbolic constants, which are defined in unistd.h, are the corresponding values used for the name argument:

System variable

Value of name (constant)

Notes

{LINK_MAX}

_PC_LINK_MAX

1.

{MAX_CANON}

_PC_MAX_CANON

2.

{MAX_INPUT}

_PC_MAX_INPUT

2.

{NAME_MAX}

_PC_NAME_MAX

3., 4.

{PATH_MAX}

_PC_PATH_MAX

4., 5.

{PIPE_BUF}

_PC_PIPE_BUF

6.

_POSIX_CHOWN_RESTRICTED

_PC_CHOWN_RESTRICTED

7.

_POSIX_NO_TRUNC

_PC_NO_TRUNC

3., 4.

_POSIX_VDISABLE

_PC_VDISABLE

2.

  1. If path or fildes refers to a directory, the value returned applies to the directory itself.

  2. If path or fildes does not refer to a special file for a terminal, the {MAX_CANON}, {MAX_INPUT} and _POSIX_VDISABLE variables are ignored.

  3. If path or fildes refers to a directory, the value returned applies to file names within the directory.

  4. If path or fildes does not refer to a directory, no association of the variables {NAME_MAX}, {PATH_MAX} and _POSIX_VDISABLE with the specified file is supported.

  5. If path or fildes refers to a directory, the value returned is the maximum length of a relative pathname when the specified directory is the working directory.

  6. If path refers to a FIFO, or fildes refers to a pipe or FIFO, the value returned applies to the referenced object. If path or fildes refers to a directory, the value returned applies to any FIFO that exists or can be created within the directory. If path or fildes refers to any other type of file, the behavior is undefined.

  7. If path or fildes refers to a directory, the value returned applies to any files, other than directories, which are defined in this standard and exist or can be created within the directory.

Return val. 

Current value of name



if successful.
The value returned will not be more restrictive than the corresponding value available to the application when it was compiled with the implementation's limits.h or unistd.h.

 

-1

if the variable corresponding to name has no limit for the path or file descriptor. errno is not set.

 

-1

if name has an invalid value or
if the implementation needs to use path or fildes to determine the value of name, and the implementation does not support the association of name with the file specified by path or fildes or
if the process did not have appropriate privileges to query the file specified by path or fildes or
if path does not exist or
if fildes is not a valid file descriptor.

In these cases, errno is set to indicate the error.

Errors

pathconf() will fail if: 

 

Extension 

 

EACCES

Search permission is denied for a component of the pathname. (End)

 

EINVAL

The value of name is not valid or
an attempt was made to access a BS2000 file.

 

Extension

 

ELOOP

Too many symbolic links were encountered in resolving path.

 

ENAMETOOLONG

 

The length of the path argument exceeds {PATH_MAX} or
a pathname component is longer than {NAME_MAX} and _POSIX_NO_TRUNC is set.

 

ENOENT

The named file does not exist or
path points to an empty string. (End)

 

ENOTDIR

A component of the path prefix is not a directory.


fpathconf() will fail if: 

 

EINVAL

The value of name is not valid or
the implementation does not support an association of the variable name with the specified file.

 

EBADF

fildes is not a valid file descriptor.

See also

sysconf(), limits.h, unistd.h.