readlink (BPX1RDL, BPX4RDL) — Read the value of a symbolic link

Function

The readlink callable service reads the contents of a symbolic link into a buffer that you provide. The symbolic link contains the pathname that was specified when the symbolic link was defined (see symlink (BPX1SYM, BPX4SYM) — Create a symbolic link to a path name).

Requirements

Operation Environment
Authorization: Supervisor state or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1RDL): 31-bit
AMODE (BPX4RDL): 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 BPX1RDL,(Link_name_length,
              Link_name,
              Buffer_length,
              Buffer_address,
              Return_value,
              Return_code,
              Reason_code)

AMODE 64 callers use BPX4RDL with the same parameters. The Buffer_address parameter is a doubleword.

Parameters

Link_name_length,
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the length of Link_name.

Link_name
Supplied parameter
Type:
Character string
Character set:
No restriction
Length:
Specified by the Link_name_length parameter

The name of a field that contains the link name of the symbolic link that is to be read. The length of this field is specified in Link_name_length.

Buffer_length
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the length, in bytes, of the buffer that is pointed to by Buffer_address.

Buffer_address
Supplied parameter
Type:
Address
Length:
Fullword (doubleword)

The name of a fullword (doubleword) that contains the address of the buffer that is supplied to readlink, into which the value of the symbolic link is to be written. The value of the symbolic link is actually the pathname that was specified when the symbolic link was created. The buffer must reside in the process's address space.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the readlink service returns a count of the number of characters placed 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 readlink service stores the return code. The readlink 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 readlink service can return one of the following values in the Return_code parameter:
Return_code Explanation
EACCES Search permission is denied for a component of the path prefix.
EINVAL The file named by Link_name is not a symbolic link; or there was a problem with the supplied buffer. The following reason codes can accompany the return code: JRFileNotSymLink, JRRdlBuffLenInvalid.
ELOOP A loop exists in symbolic links that were encountered during resolution of the Link_name argument. This error is issued if more than 24 symbolic links are detected in the resolution of Link_name.
ENAMETOOLONG Link_name is longer than 1023 characters; or some component of the link name is longer than 255 characters. Name truncation is not supported.
ENOENT No file with the name specified by Link_name was found. The following reason code can accompany the return code: JRFileNotThere.
ENOTDIR A component of the path prefix is not a directory.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the readlink service stores the reason code. The readlink 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. If the buffer that is supplied to the readlink service is too small to contain the value of the symbolic link, the value is truncated to the length of the buffer (Buffer_length). If the value that is returned is the length of the buffer, you can use the lstat service (see lstat (BPX1LST, BPX4LST) — Get status information about a file or symbolic link by path name) to determine the actual length of the symbolic link.
  2. If the Buffer_length is 0, the value that is returned is the number of bytes in the symbolic link. The buffer remains unchanged.

Related services

Characteristics and restrictions

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

Examples

For an example using this callable service, see BPX1RDL (readlink) example.