lstat (BPX1LST, BPX4LST) — Get status information about a file or symbolic link by path name

Function

The lstat callable service obtains status information about a file. The lstat service is identical to the stat service, except when the path name specified is a symbolic link (a pointer to another file or directory). In this case, the status information that is returned relates to the symbolic link, rather than to the file to which the symbolic link refers. The stat service is explained in stat (BPX1STA, BPX4STA) — Get status information about a file by pathname.

For the corresponding service using a file descriptor, see fstat (BPX1FST, BPX4FST) — Get status information about a file by descriptor.

Requirements

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

AMODE 64 callers use BPX4LST with the same parameters.

Parameters

Pathname_length
Supplied parameter
Type:
Integer
Length:
Fullword

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

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

The name of an area of length Pathname_length that contains the path name of the file for which you want to obtain status. The Pathname can be a pathname to a file, a linkname to a file (as returned by link (BPX1LNK, BPX4LNK) — Create a link to a file), or a symbolic link name (as returned by symlink (BPX1SYM, BPX4SYM) — Create a symbolic link to a path name).

Path names can begin with or without a slash.
  • A path name that begins with a slash is an absolute path name. 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 path name. The search for the file starts at the working directory.
Status_area_length
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the length of the area to which the service returns Status_area. To determine the value of Status_area_length, use macro BPXYSTAT; see BPXYSTAT — Map the response structure for stat.

Status_area
Parameter supplied and returned
Type:
Structure
Length:
Length of BPXYSTAT macro

The name of an area of length Status_area_length to which the service returns the status information for the file. Status_area is mapped by the BPXYSTAT macro; see BPXYSTAT — Map the response structure for stat.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the lstat 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 lstat service stores the return code. The lstat 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 lstat service can return one of the following values in the Return_code parameter:
Return_code Explanation
EACCES The process does not have permission to search some component of the Pathname prefix.
EINVAL Parameter error—for example, a zero-length buffer. The following reason code can accompany the return code: JRBuffTooSmall.
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 some component of the path name is longer than 255 characters. This could happen if a symbolic link was encountered during the resolution of Pathname, and the substituted string was longer than 1023 characters.
ENOENT No file named Pathname was found, or Pathname was not specified. The following reason code can accompany the return code: JRFileNotThere.
ENOTDIR A component of the Pathname prefix is not a directory.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the lstat service stores the reason code. The lstat 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. All time fields in Status_area are in POSIX format.
  2. The File Mode field in Status_area is mapped by BPXYMODE; see BPXYMODE — Map the mode constants of the file services. For information on the values for file type, see BPXYFTYP — File type definitions.
  3. If no security label (SECLABEL) exists for the file, the security label field in the Status_area contains binary zeros.

Related services

Characteristics and restrictions

To obtain information about a file, you need not have permissions for the file itself; however, you must have search permission for all of the directory components of Pathname.

Examples

For an example on the use of this system call, see BPX1LST (lstat) example.