stat(5)
NAME
stat − data returned by stat system call
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
DESCRIPTION
The system calls stat, lstat , and fstat return data whose structure is defined by this include file. The encoding of the field st_mode is defined in this file also.
The contents of the structure called stat includes the following members:
mode_tst_mode;/∗ File mode; see mknod(2) ∗/
ino_tst_ino;/∗ Inode number ∗/
dev_tst_dev;/∗ ID of device containing a ∗/
/∗ directory entry for this file ∗/
dev_tst_rdev;/∗ ID of device ∗/
/∗ This entry is defined only ∗/
/∗ for character special or ∗/
/∗ block special files ∗/
nlink_tst_nlink;/∗ Number of links ∗/
uid_tst_uid;/∗ User ID of the file’s owner ∗/
gid_tst_gid;/∗ Group ID of the file’s group ∗/
off_tst_size;/∗ File size in bytes ∗/
time_tst_atime;/∗ Time of last access ∗/
time_tst_mtime;/∗ Time of last modification ∗/
time_tst_ctime;/∗ Time of last status change ∗/
/∗ Times are measured in seconds ∗/
/∗ since 00:00:00 ∗/
unsigned long st_ausec; /∗ Time of last access in ∗/
/∗ microseconds ∗/
unsigned long st_musec; /∗ Time of last modification ∗/
/∗ in microseconds ∗/
unsigned long st_cusec; /∗ Time of last status change ∗/
/∗ in microseconds ∗/
/∗ Microsecond times are values ∗/
/∗ between 0 and 999999 and are ∗/
/∗ added to the respective ∗/
/∗ seconds fields ∗/
longst_blksize;/∗ Optimal blocksize for file ∗/
/∗ system I/O operations ∗/
longst_blocks;/ ∗ Actual number of blocks ∗/
/∗ allocated ∗/
The values for the st_mode field follows:
S_IFMTtype of file
S_IFDIRdirectory
S_IFCHRcharacter special
S_IFBLKblock special
S_IFREGregular
S_IFIFOfifo
S_IFLNKsymbolic link
S_IFSOCKsocket
S_ISUIDset user id on execution
S_ISGIDset group id on execution
S_ISVTXsave swapped text even after use
S_IREADread permission, owner
S_IWRITEwrite permission, owner
S_IEXECexecute/search permission, owner
S_ENFMTrecord locking enforcement flag
S_IRWXUread, write, execute: owner
S_IRUSRread permission: owner
S_IWUSRwrite permission: owner
S_IXUSRexecute permission: owner
S_IRWXGread, write, execute: group
S_IRGRPread permission: group
S_IWGRPwrite permission: group
S_IXGRPexecute permission: group
S_IRWXOread, write, execute: other
S_IROTHread permission: other
S_IWOTHwrite permission: other
S_IXOTHexecute permission: other
NOTES
The POSIX and SYSV stat structure does not have the st_blksize, st_blocks. These fields are 4.2BSD compatible. Their use should be avoided.
Further, in SYSV.2, the st_atime, st_mtime, and st_ctime fields are contiguous, a fact often used (and improperly so) when calling the utime(2) system service.
CX/UX returns the above version of the stucture in both the att and ucb universes. This presents a problem only to AT&T programs that use utime in the following manner:
struct stat stb;
...
utime ("path name", &stb.st_atime);
They should be changed to the more proper use:
struct stat stb;
struct utimbuf utb;
...
utb.actime = stb.st_atime;
utb.modtime = stb.st_mtime;
utime ("path name", &utb);
FILES
/usr/include/sys/types.h
/usr/include/sys/stat.h
SEE ALSO
CX/UX Programmer’s Reference Manual