fpathconf()--Get Configurable Path Name Variables by Descriptor
Syntax
#include <unistd.h> long fpathconf(int file_descriptor, int name);Service Program Name: QP0LLIB1
Default Public Authority: *USE
Threadsafe: Conditional; see Usage Notes.
The fpathconf() function determines the value of a configuration variable (name) associated with a particular file descriptor (file_descriptor). fpathconf() works exactly like pathconf(), except that it takes a file descriptor as an argument rather than taking a path name.
If file_descriptor is a descriptor for a socket, fpathconf() returns an error of [EINVAL].
Parameters
- file_descriptor
- (Input) A file descriptor of the file for which the value of the
configurable variable is requested.
- name
- (Input) The name of the configuration variable value requested.
The value of name can be any one of a set of symbols defined in the <unistd.h> include file. For more information, see pathconf()--Get Configurable Path Name Variables.
Authorities
No authorization is required.
Return Value
- value
- fpathconf() was successful. The value of the variable requested in name is returned.
- -1
- One of the following has occurred:
- A particular variable has no limit (for example, _PC_PATH_MAX). The
errno global variable is not changed.
- fpathconf() was not successful. The errno is set.
- A particular variable has no limit (for example, _PC_PATH_MAX). The
errno global variable is not changed.
Error Conditions
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] | |
[EBADF] | |
[EBADFID] | |
[EBUSY] | |
[EFAULT] | |
[EINVAL] |
For example, name is not a valid configuration variable name, or the given variable cannot be associated with the specified file. |
[EIO] | |
[ENOTAVAIL] | |
[ENOTSAFE] | |
[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] |
Error Messages
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. |
Usage Notes
- This function will fail with error code [ENOTSAFE] when all the following
conditions are true:
- Where multiple threads exist in the job.
- The object on which this function is operating resides in a file system
that is not threadsafe. Only the following file systems are threadsafe for this
function:
- "Root" (/)
- QOpenSys
- User-defined
- QNTC
- QSYS.LIB
- Independent ASP QSYS.LIB
- QOPT
- Network File System
- QFileSvr.400
- Where multiple threads exist in the job.
Related Information
- The <unistd.h> file (see Header
Files for UNIX®-Type Functions)
- open()--Open File
- pathconf()--Get Configurable Path Name
Variables
- QlgPathconf()--Get Configurable Path Name Variables
Example
The following example uses fpathconf().
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> main() { long result; char fn[]="temp.file"; int file_descriptor; if ((file_descriptor = creat(fn, S_IRUSR)) < 0) perror("creat() error"); else { errno = 0; puts("examining NAME_MAX limit for current working directory's"); puts("filesystem:"); if ((result = fpathconf(file_descriptor, _PC_NAME_MAX)) == -1) if (errno == 0) puts("There is no limit to NAME_MAX."); else perror("fpathconf() error"); else printf("NAME_MAX is %ld\n", result); close(file_descriptor); unlink(fn); } }
Output:
examining NAME_MAX limit for current working directory's filesystem: NAME_MAX is 255
API introduced: V5R2