realpath (BPX1RPH, BPX4RPH) — Resolve a path name

Function

The realpath service derives, from the pathname that is pointed to by Pathname, an absolute pathname that names the same file, whose resolution does not involve dot (.), dot-dot (..), or symbolic links.

Requirements

Operation Environment
Authorization: Supervisor state or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1RPH): 31-bit
AMODE (BPX4RPH): 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:
CALL BPX1RPH,(Pathname_length,
              Pathname,
              Resolved_name_length,
              Resolved_name,
              Return_value,
              Return_code,
              Reason_code)

AMODE 64 callers use BPX4RPH with the same parameters.

Parameters

Pathname_length
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the length of the pathname that is to be resolved.

Pathname
Supplied parameter
Type:
Character string
Character set:
No restriction
Length:
Specified by the Pathname_length parameter

The name of a field that contains the pathname that is to be resolved. The length of this field is specified in Pathname_length.

Pathnames can begin with or without a slash.
  • A path name that begins with a slash is an absolute pathname. The slash refers to the root directory, and the search for the file starts at the root directory.
  • A path name that does not begin with a slash is a relative pathname. The search for the file starts at the working directory.
Resolved_name_length
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the length of the buffer to which the realpath service returns an absolute pathname without dot (.), dot-dot (..), or symbolic links. Resolved_name_length must be large enough to accommodate the actual length of an absolute pathname, plus one (for the terminating null). A length of zero has special meaning; see the usage notes.

Resolved_name
Parameter supplied and returned
Type:
Character string
Character set:
No restriction
Length:
Specified by the Resolved_name_length parameter

The name of the buffer that is to hold the absolute pathname that is to be generated for the input Pathname. The length of this field is specified in Resolved_name_length.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the realpath 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 realpath service stores the return code. The realpath service returns Return_code only if Return_value is -1. For a list of return code values, see Return codes (errnos) in z/OS UNIX System Services Messages and Codes. The realpath service can return one of the following values in the Return_code parameter:
Return_code Explanation
EACCES The calling process does not have permission to search one of the components of Pathname.
EINVAL There was a parameter error; for example, Resolved_name_length is not valid. The following reason codes can accompany the return code: JRBuffLenInvalid and JRBadAddress.
EIO An input/output error occurred.
ELOOP A loop exists in symbolic links that were encountered during resolution of the Pathname argument. This error is issued if more than 24 symbolic links are detected in the resolution of Pathname.
ENAMETOOLONG Pathname is longer than 1023 characters; or a component of Pathname is longer than 255 characters. Name truncation is not supported.
ENOENT No file named Pathname was found; or no path name was specified. The following reason code can accompany the return code: JRFileNotThere.
ENOTDIR Some component of Pathname is not a directory.
ENOMEM Insufficient storage space is available. The following reason code can accompany the return code: JRNoStorage.
ERANGE The specified Resolved_name_length is less than the length of the pathname that was generated for the input Pathname. The specified Resolved_name_length is zero, and the length of the path name that was generated for the input Pathname is larger than PATH_MAX bytes. The following reason code can accompany the return code: JrBuffTooSmall.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the realpath service stores the reason code. The realpath service returns a Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For a list of reason codes, see Reason codes in z/OS UNIX System Services Messages and Codes.

Usage notes

  1. PATH_MAX plus 1 for the terminating null is a reasonable value for Resolved_name_length and for the size of Resolved_name.
  2. If a Resolved_name_length value of zero is passed to this service, the generated path name is stored, up to a maximum of PATH_MAX bytes, in the buffer that is pointed to by Resolved_name. Resolved_name is assumed to be of sufficient size to contain the path name that is derived by the realpath service. If the generated path name is larger than PATH_MAX, the return value is -1 and Return_code is ERANGE.

Related services

Characteristics and restrictions

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