Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (s and S) stat(2)
NAME
stat - Provides information about a le
LIBRARY
G-series native Guardian processes: system library
G-series native OSS processes: system library
H-series native Guardian processes: implicit libraries
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <sys/stat.h>
int stat(
const char *path,
struct stat *buffer);
PARAMETERS
path Points to the pathname identifying the le.
buffer Points to a stat structure, into which information is placed about
the le. The stat structure is described in the sys/stat.h header
le.
DESCRIPTION
The stat() function obtains information about the le whose name is pointed to by the path
parameter. Read, write, or execute permission for the named le is not required, but all direc-
tories listed in the pathname leading to the le must be searchable.
The le information is written to the area specied by the buffer parameter, which is a pointer to
a stat structure with this denition from the sys/stat.h header le:
struct stat {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
char ller_1[2];
uid_t st_uid;
gid_t st_gid;
char ller_2[4];
dev_t st_rdev;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
int64_t reserved[3];
};
For a regular le, the stat() function sets the st_size eld of the stat structure to the length of the
le and sets the st_mode eld to indicate the le type. For a symbolic link, the stat() function
returns information about the le at the end of the link; no information about the link is returned
(use the lstat() function for information about the link).
The stat() function updates any time-related elds associated with the le before writing into the
stat structure, unless it is a read-only leset. Time-related elds are not updated for read-only
527186-003 Hewlett-Packard Company 7159