The stat callable service obtains status information about a specified file. You specify the file by its pathname.
If the pathname that is specified refers to a symbolic link, the symbolic link name is resolved to a file, and the status information for that file is returned. To obtain status information about a symbolic link, rather than a file it refers to, use lstat (BPX1LST, BPX4LST) — Get status information about a file or symbolic link by path name.
For the corresponding service using a file descriptor, see fstat (BPX1FST, BPX4FST) — Get status information about a file by descriptor.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1STA): | 31-bit |
AMODE (BPX4STA): | 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. |
|
AMODE 64 callers use BPX4STA with the same parameters.
The name of a fullword that contains the length of Pathname.
The name of an area, of length Pathname_length, that contains the pathname of the file for which you want to obtain status. The Pathname can be a pathname to a file, a link named by a pathname to a file (as created by link (BPX1LNK, BPX4LNK) — Create a link to a file), or a symbolic link named by a pathname to a file (as created by symlink (BPX1SYM, BPX4SYM) — Create a symbolic link to a path name).
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 the BPXYSTAT macro (see BPXYSTAT — Map the response structure for stat).
The name of an area, of length Status_area_length, to which the service returns the status information for the file. The Status_area is mapped by the BPXYSTAT macro (see BPXYSTAT — Map the response structure for stat).
The name of a fullword in which the stat service returns 0 if the request is successful, or -1 if it is not successful.
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 pathname is longer than 255 characters. This could be as a result of encountering a symbolic link during resolution of Pathname, if the substituted string is 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. |
The name of a fullword in which the stat service stores the reason code. The stat 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.
To obtain information about a file, you need not have permissions for the file itself; however, you must have search permission for all the directory components of Pathname.
For an example using this callable service, see BPX1STA (stat) example.