fchdir (BPX1FCD, BPX4FCD) — Change the working directory

Function

The fchdir service changes your working directory from the current one to a new one. The working directory is the starting point for path searches of pathnames not beginning with a slash.

For corresponding service using a pathname, see chdir (BPX1CHD, BPX4CHD) — Change 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 (BPX1FCD): 31-bit
AMODE (BPX4FCD): 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 BPX1FCD,(Directory_file_descriptor,
              Return_value,
              Return_code,
              Reason_code)

AMODE 64 callers use BPX4FCD with the same parameters.

Parameters

Directory_file_descriptor
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword containing the directory file descriptor that was returned when the directory was opened (see opendir (BPX1OPD, BPX4OPD) — Open a directory), which is to become the new working directory. It may also be specified as the name of a fullword containing the file descriptor of an open directory (see open (BPX1OPN, BPX4OPN) — Open a file).

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword where the fchdir service returns 0 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 fchdir service stores the return code. The fchdir service returns Return_code only if Return_value is -1. See z/OS UNIX System Services Messages and Codes for a complete list of possible return code values. The fchdir service can return one of the following values in the Return_code parameter:
Return_code Explanation
EACCES The calling process does not have search permission for the directory referenced by the file descriptor.
EBADF The file descriptor parameter is not a valid file descriptor.
ENOTDIR The open file descriptor does not refer to a directory. The following reason code can accompany the return code: JRChdNotDir.
EINTR A signal was caught during the execution of fchdir().
EIO An I/O error occurred while reading from or writing to the file system. The following reason codes can accompany the return code: JRQuiescing.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword where the fchdir service stores the reason code. The fchdir service returns a Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. See z/OS UNIX System Services Messages and Codes for the reason codes.

Related services

Characteristics and restrictions

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

Examples

For an example using this callable service, see BPX1FCD (fchdir) example.