opendir (BPX1OPD, BPX4OPD) — Open a directory
Function
The opendir callable service opens a directory so that it can be read with the readdir service.
Requirements
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1OPD): | 31-bit |
AMODE (BPX4OPD): | 64-bit |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
Format
|
AMODE 64 callers use BPX4OPD with the same parameters.
Parameters
- Directory_name_length
- Supplied parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword that contains the length of the name of the directory.
- Directory_name
- Supplied parameter
- Type:
- Character string
- Character set:
- No restriction
- Length:
- Specified by the Directory_name_length
The name of a field that contains the name of the directory. The length of this field is specified in Directory_name_length.
- Return_value
- Returned parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword in which the opendir service stores a directory file descriptor that describes the specified directory, if the request is successful; or -1, if it is not successful.
- Return_code
- Returned parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword in which the opendir service stores the return code. The opendir service returns Return_code only if Return_value is -1. See z/OS UNIX System Services Messages and Codes for a complete list of possible return code values. The opendir service can return one of the following values in the Return_code parameter:Return_code Explanation EACCES The process does not have permission to search some component of the name that is specified as Directory_name; or it does not have permission to work with the directory itself. ELOOP A loop exists in symbolic links that were encountered during resolution of the Directory_name argument. This error is issued if more than 24 symbolic links are detected in the resolution of Directory_name. EMFILE Too many other files are already open for the process. ENAMETOOLONG Directory_name is longer than 1023 bytes; or a component of the pathname is more than 255 bytes long. ENFILE Too many files are already open. ENOENT The specified directory was not found. The following reason codes can accompany the return code: JROpenDirNotFound and JRQuiescing. ENOTDIR Some component of the pathname is not a directory. The following reason code can accompany the return code: JRTargetNotDir. - Reason_code
- Returned parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword in which the opendir service stores the reason code. The opendir service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.
Usage notes
- The opendir service opens a directory so that the first readdir service—see readdir (BPX1RDD, BPX4RDD) — Read an entry from a directory—starts reading at the first entry in the directory.
- Return_value is a file descriptor for a directory only. It can be used only as input to services that expect a directory file descriptor. These services are closedir, rewinddir, and readdir.
Related services
Characteristics and restrictions
There are no restrictions on the use of the opendir service.
Examples
For an example using this callable service, see BPX1OPD (opendir) example.