#include <unistd.h> long pathconf(const char *path, int name);Service Program Name: QP0LLIB1
The pathconf() function lets an application determine the value of a configuration variable (name) associated with a particular file or directory (path).
If the named file is a symbolic link, pathconf() resolves the symbolic link.
This parameter is assumed to be represented in the CCSID (coded character set identifier) currently in effect for the process. If the CCSID of the job is 65535, this parameter is assumed to be represented in the default CCSID of the job.
See QlgPathconf()--Get Configurable Path Name Variables for a description and an example of supplying the path in any CCSID.
The value of name can be any one of the following set of symbols defined in the <unistd.h> header file, each standing for a configuration variable:
Represents LINK_MAX, which indicates the maximum number of links the file can have. If path is a directory, pathconf() returns the maximum number of links that can be established to the directory itself.
Represents MAX_CANON, which indicates the maximum number of bytes in a terminal canonical input line.
Represents MAX_INPUT, which indicates the minimum number of bytes for which space is available in a terminal input queue. This available space is the maximum number of bytes that a portable application can have the user enter before the application actually reads the input.
Represents NAME_MAX, which indicates the maximum number of bytes in a file name (not including any terminating null at the end if the file name is stored as a string). This symbol refers only to the file name itself; that is, the last component of the path name of the file. pathconf() returns the maximum length of file names, even when the path does not refer to a directory.
This value is the number of bytes allowed in the file name if it were encoded in the CCSID of the job. If the CCSID is mixed, this number is an estimate and may be larger than the actual allowable maximum.
Represents PATH_MAX, which indicates the maximum number of bytes in a complete path name (not including any terminating null at the end if the path name is stored as a string). pathconf() returns the maximum length of a relative path name relative to path, even when path does not refer to a directory.
This value is the number of bytes allowed in the path name if it were encoded in the CCSID of the job. If the CCSID is mixed, this number is an estimate and may be larger than the actual allowable maximum.
Represents PIPE_BUF, which indicates the maximum number of bytes that can be written "atomically" to a pipe. If more than this number of bytes are written to a pipe, the operation may take more than one physical write operation and physical read operation to read the data on the other end of the pipe. If path is a FIFO special file, pathconf() returns the value for the file itself. If path is a directory, pathconf() returns the value for any FIFOs that exist or that can be created under the directory. If path is any other kind of file, an error of [EINVAL] is returned.
Represents _POSIX_CHOWN_RESTRICTED, as defined in the <unistd.h> header file. It restricts use of chown() to a job with appropriate privileges, and allows the group ID of a file to be changed only to the effective group ID of the job or to one of its supplementary group IDs. If path is a directory, pathconf() returns the value for any kind of file under the directory, but not for subdirectories of the directory.
Represents _POSIX_NO_TRUNC, as defined in the <unistd.h> header file. It generates an error if a file name is longer than NAME_MAX. If path refers to a directory, the value returned by pathconf() applies to all files under that directory.
Represents _POSIX_VDISABLE, as defined in the <unistd.h> header file. This symbol indicates that terminal special characters can be disabled using this character value, if it is defined.
This symbol is used to determine if the object represented by path resides in a threadsafe file system. pathconf() returns the value 1 if the file system is threadsafe and 0 if the file system is not threadsafe. fpathconf() will never fail with error code [ENOTSAFE] when called with _PC_THREAD_SAFE.
Note: Adopted authority is not used.
Authorization required for pathconf()
Object Referred to | Authority Required | errno |
---|---|---|
Each directory in the path name preceding the object | *X | EACCES |
Object | None | None |
If fpathconf() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
Error condition | Additional information |
---|---|
[EACCES] |
If you are accessing a remote file through the Network File System, update operations to file permissions at the server are not reflected at the client until updates to data that is stored locally by the Network File System take place. (Several options on the Add Mounted File System (ADDMFS) command determine the time between refresh operations of local data.) Access to a remote file may also fail due to different mappings of user IDs (UID) or group IDs (GID) on the local and remote systems. |
[EAGAIN] | |
[EBADFID] | |
[EBADNAME] | |
[EBUSY] | |
[ECONVERT] | |
[EDAMAGE] | |
[EFAULT] | |
[EFILECVT] | |
[EINTR] | |
[EINVAL] |
For example, name is not a valid configuration variable name, or the given variable cannot be associated with the specified file. |
[EIO] | |
[EISDIR] | |
[ELOOP] | |
[ENAMETOOLONG] | |
[ENOENT] | |
[ENOMEM] | |
[ENOSPC] | |
[ENOTAVAIL] | |
[ENOTDIR] | |
[ENOTSAFE] | |
[ENOTSUP] | |
[EPERM] | |
[EROOBJ] | |
[ESTALE] |
If you are accessing a remote file through the Network File System, the file may have been deleted at the server. |
[EUNKNOWN] |
If interaction with a file server is required to access the object, errno could indicate one of the following errors:
Error condition | Additional information |
---|---|
[EADDRNOTAVAIL] | |
[ECONNABORTED] | |
[ECONNREFUSED] | |
[ECONNRESET] | |
[EHOSTDOWN] | |
[EHOSTUNREACH] | |
[ENETDOWN] | |
[ENETRESET] | |
[ENETUNREACH] | |
[ESTALE] |
If you are accessing a remote file through the Network File System, the file may have been deleted at the server. |
[ETIMEDOUT] | |
[EUNATCH] |
The following messages may be sent from this function:
Message ID | Error Message Text |
---|---|
CPE3418 E | Possible APAR condition or hardware failure. |
CPFA0D4 E | File system error occurred. Error number &1. |
CPF3CF2 E | Error(s) occurred during running of &1 API. |
CPF9872 E | Program or service program &1 in library &2 ended. Reason code &3. |
See Code disclaimer information for information pertaining to code examples.
The following example determines the maximum number of bytes in a file name:
#include <stdio.h> #include <unistd.h> #include <errno.h> main() { long result; errno = 0; puts("examining NAME_MAX limit for root filesystem"); if ((result = pathconf("/", _PC_NAME_MAX)) == -1) if (errno == 0) puts("There is no limit to NAME_MAX."); else perror("pathconf() error"); else printf("NAME_MAX is %ld\n", result); }
Output:
examining NAME_MAX limit for root filesystem NAME_MAX is 255
Top | UNIX-Type APIs | APIs by category |