fstat (BPX1FST, BPX4FST) — Get status information about a file by descriptor

Function

The fstat callable service obtains status information about a file. You identify the file by its file descriptor.

Requirements

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

AMODE 64 callers use BPX4FST with the same parameters.

Parameters

File_descriptor
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the file descriptor for the file.

Status_area_length
Supplied parameter
Type:
Integer
Length:
Fullword

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

Status_area
Parameter supplied and returned
Type:
Structure
Length:
The length of BPXYSTAT or Status_area_length, whichever is less.

The name of an area to which the fstat call returns the status information for the file. Status_area is mapped by the BPXYSTAT macro. For information on the contents of this macro, see BPXYSTAT — Map the response structure for stat.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword where the fstat 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 fstat service stores the return code. The fstat 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 fstat service can return one of the following values in the Return_code parameter:
Return_code Explanation
EBADF The File_descriptor parameter does not identify a known file. One possible reason for this is that the file descriptor specified is from an opendir instead of an open, in which case JrNotForDir is returned as the reason code.
EINVAL Parameter error; for example, a zero-length buffer was passed. 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 fstat service stores the reason code. The fstat 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 the Status_area are in POSIX format.
  2. The file mode field in the Status_area is mapped by BPXYMODE, and the file type field within the mode area is mapped by BPXYFTYP. For information about these fields, see BPXYMODE — Map the mode constants of the file services and BPXYFTYP — File type definitions.
  3. When the mode of an open file is changed using a service such as chmod(), an fstat() reflects the change in mode. However, no change in access authorization is apparent when the file is accessed through a previously opened file descriptor.
  4. 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

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

Examples

For an example using this callable service, see BPX1FST (fstat) example.