stat(5) stat(5)
NAME
stat - data returned by the stat() function
SYNOPSIS
#include <sys/stat.h>
DESCRIPTION
The <sys/stat.h> header defines the structure of the data returned by
the functions fstat(), lstat(), and stat().
The structure stat contains at least the following members:
devt stdev ID of device containing file
inot stino file serial number
modet stmode mode of file (see below)
nlinkt stnlink number of links to the file
uidt stuid user ID of file
gidt stgid group ID of file
devt strdev device ID (if file is character or block special)
offt stsize file size in bytes (if file is a regular file)
timet statime time of last access
timet stmtime time of last data modification
timet stctime time of last status change
long stblksize a file system-specific preferred I/O block size
for this object. In some file system types, this
may vary from file to file.
blkcntt stblocks number of blocks of a file system-specific size
allocated for this object.
File serial number and device ID taken together uniquely identify the
file within the system. The devt, inot, modet, nlinkt, uidt,
gidt, offt and timet types are defined as described in
<sys/types.h>. Times are given in seconds since the Epoch.
The following symbolic names for the values of stmode are also
defined:
File type:
SIFMT type of file
SIFBLK block special
SIFCHR character special
SIFIFO FIFO special
SIFREG regular
SIFDIR directory
SIFLNK symbolic link
SIFSOCK socket
Page 1 Reliant UNIX 5.44 Printed 11/98
stat(5) stat(5)
File mode bits:
SIRWXU read, write, execute/search by owner
SIRUSR read permission, owner
SIWUSR write permission, owner
SIXUSR execute/search permission, owner
SIRWXG read, write, execute/search by group
SIRGRP read permission, group
SIWGRP write permission, group
SIXGRP execute/search permission, group
SIRWXO read, write, execute/search by others
SIROTH read permission, others
SIWOTH write permission, others
SIXOTH execute/search permission, others
SISUID set-user-ID on execution
SISGID set-group-ID on execution
SISVTX on directories, restricted deletion flag
SIAMB access mode bits
SENFMT record locking enforcement flag
The bits defined by SIRUSR, SIWUSR, SIXUSR, SIRGRP, SIWGRP,
SIXGRP, SIROTH, SIWOTH, SIXOTH, SISUID, SISGID and SISVTX are
unique.
SIRWXU is the bitwise OR of SIRUSR, SIWUSR and SIXUSR.
SIRWXG is the bitwise OR of SIRGRP, SIWGRP and SIXGRP.
SIRWXO is the bitwise OR of SIROTH, SIWOTH and SIXOTH.
Implementations may OR other implementation-dependent bits into
SIRWXU, SIRWXG and SIRWXO, but they will not overlap any of the
other bits defined in this description. The file permission bits are
defined to be those corresponding to the bitwise inclusive OR of
SIRWXU, SIRWXG and SIRWXO.
The following macros are for POSIX conformance. They will test whether
a file is of the specified type. The value m supplied to the macros is
the value of stmode from a stat structure. The macro evaluates to a
non-zero value if the test is true, 0 if the test is false.
SISBLK(m) Test for a block special file.
SISCHR(m) Test for a character special file.
SISDIR(m) Test for a directory.
SISFIFO(m) Test for a pipe or FIFO special file.
SISREG(m) Test for a regular file.
SISLNK(m) Test for a symbolic link.
Page 2 Reliant UNIX 5.44 Printed 11/98
stat(5) stat(5)
SISSOCK(m) Test for a socket.
The following are declared as functions and may also be defined as
macros:
int chmod(const char *path, modet mode);
int fchmod(int fildes, modet mode);
int fstat(int fildes, struct stat *buf);
int lstat(const char *path, struct stat *buf);
int mkdir(const char *path, modet mode);
int mkfifo(const char *path, modet mode);
int mknod(const char *path, modet mode, devt dev);
int stat(const char *path, struct stat *buf);
modet umask(modet cmask);
The stat64 structure is defined in the same way as the stat structure
with the exception of the following members:
ino64t stino File serial number.
off64t stsize File size in bytes.
blkcnt64t stblocks Number of blocks allocated for this object.
The following are declared as functions and may also be defined as
macros:
int fstat64(int fildes, struct stat64 *buf);
int lstat64(const char *, struct stat64 *buf);
int stat64(const char *, struct stat64 *buf);
SEE ALSO
chmod(2), fchmod(2), fstat(2), lstat(2), mkdir(2), mknod(2), stat(2),
umask(2), mkfifo(3C), lfs(5), types(5).
Page 3 Reliant UNIX 5.44 Printed 11/98