pathconf or fpathconf Subroutine
Purpose
Retrieves file-implementation characteristics.
Library
Standard C Library (libc.a)
Syntax
#include <unistd.h>
int FileDescriptor, Name;
Description
The pathconf subroutine allows an application to determine the characteristics of operations supported by the file system contained by the file named by the Path parameter. Read, write, or execute permission of the named file is not required, but all directories in the path leading to the file must be searchable.
The fpathconf subroutine allows an application to retrieve the same information for an open file.
Parameters
Item | Description |
---|---|
Path | Specifies the path name. |
FileDescriptor | Specifies an open file descriptor. |
Name | Specifies the configuration attribute to be queried. If this
attribute is not applicable to the file specified by the Path or FileDescriptor parameter,
the pathconf subroutine returns an error. Symbolic values
for the Name parameter are defined in the unistd.h file:
|
- If the Name parameter has a value of _PC_LINK_MAX, and if the Path or FileDescriptor parameter refers to a directory, the value returned applies to the directory itself.
- If the Name parameter has a value of _PC_NAME_MAX or _PC_NO_TRUNC, and if the Path or FileDescriptor parameter refers to a directory, the value returned applies to filenames within the directory.
- If the Name parameter has a value if _PC_PATH_MAX, and if the Path or FileDescriptor parameter refers to a directory that is the working directory, the value returned is the maximum length of a relative pathname.
- If the Name parameter has a value of _PC_PIPE_BUF, and if the Path parameter refers to a FIFO special file or the FileDescriptor parameter refers to a pipe or a FIFO special file, the value returned applies to the referenced object. If the Path or FileDescriptor parameter refers to a directory, the value returned applies to any FIFO special file that exists or can be created within the directory.
- If the Name parameter has a value of _PC_CHOWN_RESTRICTED, and if the Path or FileDescriptor parameter refers to a directory, the value returned applies to any files, other than directories, that exist or can be created within the directory.
Return Values
If the pathconf or fpathconf subroutine is successful, the specified parameter is returned. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error. If the variable corresponding to the Name parameter has no limit for the Path parameter or the FileDescriptor parameter, both the pathconf and fpathconf subroutines return a value of -1 without changing the errno global variable.
Error Codes
The pathconf or fpathconf subroutine fails if the following error occurs:
Item | Description |
---|---|
EINVAL | The name parameter specifies an unknown or inapplicable characteristic. |
The pathconf subroutine can also fail if any of the following errors occur:
Item | Description |
---|---|
EACCES | Search permission is denied for a component of the path prefix. |
EINVAL | The implementation does not support an association of the Name parameter with the specified file. |
ENAMETOOLONG | The length of the Path parameter string exceeds the PATH_MAX value. |
ENAMETOOLONG | Pathname resolution of a symbolic link produced an intermediate result whose length exceeds PATH_MAX. |
ENOENT | The named file does not exist or the Path parameter points to an empty string. |
ENOTDIR | A component of the path prefix is not a directory. |
ELOOP | Too many symbolic links were encountered in resolving path. |
The fpathconf subroutine can fail if either of the following errors occur:
Item | Description |
---|---|
EBADF | The File Descriptor parameter is not valid. |
EINVAL | The implementation does not support an association of the Name parameter with the specified file. |