The following code opens file
usr/inv/nov.d. with
user read-write, group read and other read, and obtains status about
the file. A file descriptor (FILEDESC) is returned.
For the callable service, see
openstat (BPX2OPN, BPX4OPS) — Open a file and obtain status information.
For the data structures, see
BPXYOPNF — Map flag values for open,
BPXYSTAT — Map the response structure for stat,
BPXYMODE — Map the mode constants of the file services, and
BPXYFTYP — File type definitions. AMODE 31 callers use
BPX2OPN (openstat) example.
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 BPX4OPS, Open a file and get status +
(BUFLENA, Input: Pathname length +
BUFFERA, Input: Pathname +
O_FLAGS, Input: Access BPXYOPNF +
S_MODE, Input: Mode BPXYMODE, BPXYFTYP +
STATL, Input: Length of buffer needed +
STAT, Buffer, BPXYSTAT +
RETVAL, Return value:-1 or file descriptor+
RETCODE, Return code +
RSNCODE), Reason code +
MF=(E,PLIST) ----------------------------------
ICM R15,B'1111',RETVAL Test RETVAL
BL PSEUDO Branch if negative (-1 = failure)
ST R15,FILEDESC Store the file descriptor