The open callable service gains access to a file and creates a file descriptor for it.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1OPN): | 31-bit |
AMODE (BPX4OPN): | 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 BPX4OPN with the same parameters.
The name of a fullword that contains the length of the Pathname of the file.
The name of a field that contains the name of the file to be opened. The length of this field is specified in Pathname_length.
The name of a fullword that contains the binary flags that describe how the file is to be opened. For descriptions of the options, see Usage notes.
Options are mapped by the BPXYOPNF macro; see BPXYOPNF — Map flag values for open.
The name of a fullword in which the mode field is specified. The mode field, which is mapped by BPXYMODE, specifies the file type and the permissions the caller grants to itself, to its groups, and to any user. See BPXYMODE — Map the mode constants of the file services.
If create or exclusive create is not specified on the Options parameter, the Mode parameter is ignored.
The file type is mapped by the BPXYFTYP macro; see BPXYFTYP — File type definitions.
The name of a fullword in which the open service stores the file descriptor if the file was opened successfully, or -1 if it is not successful.
Return_code | Explanation |
---|---|
EACCES | Reasons for being denied access include these:
|
EAGAIN | Resources were temporarily unavailable. |
EBUSY | The path name specifies a master pseudoterminal that is either already in use or for which the corresponding slave is open, or the file is open by a remote NFS client with a share reservation that conflicts with the requested operation |
EEXIST | The exclusive create option was specified, but the file already exists. The following reason code can accompany the return code: JRFileExistsExclFlagSet. |
EFBIG | A request to create a new file is prohibited because the file size limit for the process is set to 0. |
EINTR | The open operation was interrupted by a signal. |
EINVAL | The Options parameter does not specify a valid combination of the O_RDONLY, O_WRONLY and O_TRUNC bits; or the file type that was specified in the Mode parameter is not valid. The following reason codes can accompany the return code: JRInvOpenFlags and JROpenFlagConflict. |
EISDIR | The file specified by Pathname is a directory, and the Options parameter specifies write or read/write access. The following reason code can accompany the return code: JRDirWriteRequest. |
ELOOP | A loop exists in symbolic links that were encountered during resolution of the Pathname argument. This error is issued if more than 24 symbolic links are detected in the resolution of Pathname. |
EMFILE | The process has either reached the maximum number of file descriptors it can have open, or the current pipe limit was exceeded. Refer to the reason code that was provided. |
ENAMETOOLONG | The path name is longer than 1023 characters, or a component of the path name is longer than 255 characters. File names cannot be truncated. |
ENFILE | The maximum number of file descriptors that can be open has been reached. |
ENODEV | Typical causes:
The following reason code can accompany the return code: JRNoCTTY. |
ENOENT | Typical causes:
The following reason codes can accompany the return code: JREndingSlashOCreat, JRNoFileNoCreatFlag, and JRQuiescing. |
ENOSPC | The directory or file system intended to hold a new file has insufficient space. |
ENOTDIR | A component of Pathname is not a directory. |
ENXIO | The open request specified write-only and nonblock for a FIFO special file, but no process has the file open for reading. For pseudoterminals, it can mean that the minor number associated with the pathname is too big. |
EPERM | The caller is not permitted to open the specified slave pseudoterminal; or the corresponding master is not yet open. EPERM is also returned if the slave is closed with HUPCL set, and an attempt is made to reopen it. |
EROFS | The Pathname parameter names a file on a read-only file system, but options that would allow the file to be altered were specified: write-only, read/write, truncate, or—for a new file—create. The following reason codes can accompany the return code: JRReadOnlyFileSetWriteReq and JRReadOnlyFileSetCreatReq. |
The name of a fullword in which the open service stores the reason code. The open 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.
See Usage notes.
See BPX1OPN (open) example for an example using this callable service.
The Execution access requested bit is used by the exec service (see exec (BPX1EXC, BPX4EXC) — Run a program) to verify that the process has permission to run the specified file. When the open service succeeds, the specified file is treated as read-only for this case.