getcwd (BPX1GCW, BPX4GCW) — Get the pathname of the working directory

Function

The getcwd callable service gets the pathname of the working directory.

Requirements

Operation Environment
Authorization: Supervisor state or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1GCW): 31-bit
AMODE (BPX4GCW): 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

CALL BPX1GCW,(Buffer_length,
              Buffer,
              Return_value,
              Return_code,
              Reason_code)

AMODE 64 callers use BPX4GCW with the same parameters.

Parameters

Buffer_length
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the length of the buffer to which the getcwd service returns the pathname of the directory. Buffer_length must be large enough to accommodate the actual length of the pathname plus one (for the terminating null).

Buffer
Parameter supplied and returned
Type:
Character string
Character set:
No restrictions
Length:
Specified by the Buffer_length parameter

The name of the buffer that is to hold the pathname of the working directory.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the getcwd service returns the length of the pathname that is in the buffer, 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 getcwd service stores the return code. The getcwd service returns Return_code only if Return_value is -1. For a complete list of possible return code values, see z/OS UNIX System Services Messages and Codes. The getcwd service can return one of the following values in the Return_code parameter:
Return_code Explanation
EACCES The process did not have permission to read or search a component of the working directory's pathname.
EINVAL Buffer_length was specified as zero. The following reason code can accompany the return code: JRBufLenInvalid.
EIO An input/output error occurred.
ENOENT A component of a pathname does not exist. This will be returned if a component of the working directory pathname was deleted.
ERANGE The specified Buffer_length is less than the length of the pathname of the working directory.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the getcwd service stores the reason code. The getcwd 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.

Related services

Characteristics and restrictions

There are no restrictions on the use of the getcwd service.

Examples

For an example using this callable service, see BPX1GCW (getcwd) example.