Accesses information about the specified file.
#include <stat.h> int stat (const char *file_spec, struct stat *buffer); (ISO POSIX-1) int stat (const char *file_spec, struct stat *buffer, . . . ); (DEC C Extension)Function Variants Compiling with the _DECC_V4_SOURCE and _VMS_V6_SOURCE feature- test macros defined enables a local-time-based entry point to this function that is equivalent to the behavior before OpenVMS Version 7.0.
The argument receives information about the particular file. The members of the structure pointed to by buffer are described as follows:
Member | Type | Definition |
---|---|---|
st_dev | dev_ t | Pointer to the physical device name |
st_ino[3] | ino_t | Three words to receive the file ID |
st_ mode | mode_t | File "mode" (prot, dir, . . . ) |
st_nlink | nlink_ t | For UNIX system compatibility only |
st_uid | uid_t | Owner user ID |
st_gid | gid_t | Group member: from st_uid |
st_ rdev | dev_t | UNIX system compatibility - always 0 |
st_size | off_ t | File size, in bytes |
st_atime | time_t | File access time; always the same as st_mtime |
st_ mtime | time_t | Last modification time |
st_ctime | time_ t | File creation time |
st_ fab_rfm | char | Record format |
st_fab_rat | char | Record attributes |
st_fab_fsz | char | Fixed header size |
st_fab_mrs | unsigned | Record size |
The types dev_t, ino_t, off_t, mode_t, nlink_t, uid_t, gid_t, and time_t, are defined in the <stat.h> header file. However, when compiling for compatibility (/DEFINE=_DECC_V4_SOURCE), only dev_ t, ino_t, and off_t are defined.
As of OpenVMS Version 7.0, times are given in seconds since the Epoch (00:00:00 GMT, January 1, 1970).
The st_mode structure member is the status information mode defined in the <stat.h> header file. The st_mode bits are described as follows:
Bits | Constant | Definition |
---|---|---|
0170000 | S_IFMT | Type of file |
0040000 | S_IFDIR | Directory |
0020000 | S_IFCHR | Character special |
0060000 | S_IFBLK | Block special |
0100000 | S_IFREG | Regular |
0030000 | S_IFMPC | Multiplexed char special |
0070000 | S_ IFMPB | Multiplexed block special |
0004000 | S_ISUID | Set user ID on execution |
0002000 | S_ ISGID | Set group ID on execution |
0001000 | S_ISVTX | Save swapped text even after use |
0000400 | S_ IREAD | Read permission, owner |
0000200 | S_IWRITE | Write permission, owner |
0000100 | S_ IEXEC | Execute/search permission, owner |
If the file is a record file, the st_size field includes carriage- control information. Consequently, the st_size value will not correspond to the number of characters that can be read from the file.
0 | Indicates success. |
-1 | Indicates an error other than a privilege violation; errno is set to indicate the error. |
-2 | Indicates a privilege violation. |