getwd (BPX1GWD, BPX4GWD) — Get the path name of the working directory

Function

The getwd callable service gets the path name 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 (BPX1GWD): 31-bit
AMODE (BPX4GWD): 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

The syntax format is as follows:

AMODE 64 callers use BPX4GWD 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 getwd 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). Length of zero has special meaning; see the usage notes.

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 will hold the pathname of the working directory.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the getwd 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 getwd service stores the return code. The getwd 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 getwd 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 The Buffer_length specified was not valid. 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 is 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. The specified Buffer_length is zero, and the length of the pathname of the working directory is larger than PATH_MAX bytes.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

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

Usage notes

  1. PATH_MAX plus 1 for the terminating null character is a reasonable size for the Buffer.
  2. If a Buffer_length of zero is passed to this service, the generated null terminated pathname is stored in the named buffer up to a maximum of PATH_MAX + 1 bytes. Buffer is assumed to be of sufficient size to contain the pathname derived by the getwd service. If the generated pathname is larger than PATH_MAX bytes, the return value is -1 and Return_code is ERANGE.

Characteristics and restrictions

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

Examples

For an example using this callable service, see BPX1GWD (getwd) example.