STAT(2) DOMAIN/IX Reference Manual (SYS5) STAT(2)
NAME
stat, fstat, lstat - get file or link status
USAGE
#include <sys/types.h>
#include <sys/stat.h>
int stat (path, buf)
char *path;
struct stat *buf;
int lstat (path, buf)
char *path;
struct stat *buf;
int fstat (fildes, buf)
int fildes;
struct stat *buf;
DESCRIPTION
Path points to a filename. Read, write, or execute permis-
sion of the named file is not required, but all directories
listed in the pathname leading to the file must be search-
able. Stat obtains information about the named file.
Lstat behaves like stat unless path is a soft (or symbolic)
link, in which case lstat returns information on the link
itself.
Fstat obtains information about the open file known by the
file descriptor fildes, The file descriptor is returned by a
successful open, creat, dup, fcntl, or pipe system call.
Buf is a pointer to a stat structure into which information
about the file is placed.
The contents of the structure that buf points to include the
following members:
ushort st_mode; /* File mode; see mknod(2) */
ino_t st_ino; /* Inode number */
dev_t st_dev; /* ID of device containing */
/* a directory entry for this file
*/
dev_t st_rdev; /* ID of device */
/* This entry is defined only for
*/
/* character special or block spe-
cial files */
short st_nlink; /* Number of hard links */
ushort st_uid; /* User ID of the file's owner */
Printed 1/27/86 STAT-1
STAT(2) DOMAIN/IX Reference Manual (SYS5) STAT(2)
ushort st_gid; /* Group ID of the file's group */
off_t st_size; /* File size in bytes */
time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last data modification
*/
time_t st_ctime; /* Time of last file status change
*/
/* Times measured in seconds since
*/
/* 00:00:00 GMT, Jan. 1, 1970 */
st_atime Time when file data was last accessed. Changed by
the following system calls: creat(2), mknod(2),
pipe(2), utime(2), and read(2).
st_mtime Time when data was last modified. Changed by the
following system calls: creat(2), mknod(2),
pipe(2), utime(2), and write(2).
st_ctime Time when file status was last changed. Changed
by the following system calls: chmod(2), chown(2),
creat(2), link(2), mknod(2), pipe(2), unlink(2),
utime(2), and write(2).
RETURN VALUE
The stat and fstat calls return zero upon successful comple-
tion. Otherwise, they return -1 and set errno to indicate
the error.
ERRORS
Both sta and lstat fail if one or more of the following is
true:
[ENOTDIR] A component of the path prefix is not a directory.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied for a component of the
path prefix.
[EFAULT] Buf or path points to an invalid address.
[ELOOP] The call encountered too many soft (or symbolic)
links in the path.
Fstat fails if one or more of the following is true:
[EBADF] Fildes is not a valid open file descriptor.
[EFAULT] Buf points to an invalid address.
STAT-2 Printed 1/27/86
STAT(2) DOMAIN/IX Reference Manual (SYS5) STAT(2)
RELATED INFORMATION
chmod(2)
chown(2)
creat(2)
link(2)
mknod(2)
pipe(2)
read(2)
soft_link(2)
soft_unlink(2)
time(2)
unlink(2)
utime(2)
write(2)
Printed 1/27/86 STAT-3