BPX1OPN (open) example
The following code opens file usr/inv/nov.d with
user read-write, group read and other read. A file descriptor (FILEDESC)
is returned. For the callable service, see open (BPX1OPN, BPX4OPN) — Open a file.
For the data structure, see BPXYOPNF — Map flag values for open,
AMODE 64 callers use BPX4OPN (open) example. BPXYMODE — Map the mode constants of the file services, and BPXYFTYP — File type definitions.
MVC BUFFERA(13),=CL13'usr/inv/nov.d'
MVC BUFLENA,=F'13'
XC S_MODE,S_MODE
MVI S_MODE2,S_IRUSR User read/write, group read,
MVI S_MODE3,S_IWUSR+S_IRGRP+S_IROTH other read
XC O_FLAGS(OPNF#LENGTH),O_FLAGS
MVI O_FLAGS4,O_CREAT+O_RDWR Create, open for read and write
SPACE ,
CALL BPX1OPN, Open a file +
(BUFLENA, Input: Pathname length +
BUFFERA, Input: Pathname +
O_FLAGS, Input: Access BPXYOPNF +
S_MODE, Input: Mode BPXYMODE, BPXYFTYP +
RETVAL, Return value:-1 or file descriptor+
RETCODE, Return code +
RSNCODE), Reason code +
VL,MF=(E,PLIST) ----------------------------------
ICM R15,B'1111',RETVAL Test RETVAL
BL PSEUDO Branch if negative (-1 = failure)
ST R15,FILEDESC Store the file descriptor