The readdir2 callable service reads multiple name entries from a directory.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1RD2): | 31-bit |
AMODE (BPX4RD2): | 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. |
|
AMODE 64 callers use BPX4RD2 with the same parameters. Some of the addresses in the UIO structure are doublewords.
The name of a fullword that contains the directory file descriptor that was returned when the directory was opened (see opendir (BPX1OPD, BPX4OPD) — Open a directory).
The name of an area that contains the user input and output block. This area is mapped by the BPXYFUIO macro (see BPXYFUIO — Map file system user I/O block).
The name of a fullword in which the readdir2 service returns the number of directory entries that have been read into the buffer that is pointed to by the UIO, or -1 if the request is unsuccessful. A value of 0 in Return_value indicates the end of the directory.
Return code | Explanation |
---|---|
EACCES | The FuioChkAcc bit was set to request that an access check be performed, but the calling process does not have permission to read the specified directory. |
EBADF | The Directory_file_descriptor argument does not refer to an open directory. |
EINVAL | There was a parameter error; for example, a supplied area was too small. The following reason codes can accompany the return code: JRInvalidFuio,JrBytes2RWZero, JRRddPlusNoCursorSupp |
The name of a fullword in which the readdir2 service stores the reason code. The readdir2 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.
The entries are packed together, and the length fields are not aligned on any particular boundary.
In addition, some physical file systems may return a null name entry as the last entry in the caller's buffer. A null name entry has an Entry_length of 4 and a Name_length of 0. The caller of the readdir2 service should check for both conditions.
Because this index represents the number of entries into the directory, the caller should be aware that if entries are being added or deleted in the directory while the call is being done, duplicate or missing entries could result.
The cursor protocol is preferred for better performance.
There are no restrictions on the use of the readdir2 service.
For an example using this callable service, see BPX1RD2 (readdir2) example.