DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

stat(5)


stat -- data returned by stat and stat64 system call

Synopsis

   #include <sys/types.h>
   #include <sys/stat.h>

Description

The stat.h header defines the stat structure and the stat64 structure, in which the system calls stat(2), stat64(2), lstat(2), lstat64(2), fstat(2), and fstat64(2) return data. They include the following members:
   dev_t    st_dev;			/* ID of device containing a directory */
   				/* entry for this file */
   ino_t    st_ino; +		 	/* Inode number */
   mode_t   st_mode;			/* File mode [see mknod)] */
   nlink_t  st_nlink;			/* Number of links */
   uid_t    st_uid;			/* User ID of the file's owner */
   gid_t    st_gid;			/* Group ID of the file's group */
   dev_t    st_rdev;			/* ID of device. This entry is defined only */
   				/* for char special or block special files */
   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 UTC, Jan. 1, 1970 */
   long     st_blksize;		/* Preferred I/O block size */
   blkcnt_t st_blocks; +		/* Number of 512 blocks allocated */
                           		/*A files residing on an s5 filesystem */
                           		/*reports number of blocks allocated */
                           		/*assuming no holes in the file */
   char     st_fstype[_ST_FSTYPSZ];	/* name of filesystem type */
   int      st_aclcnt;		/* number of ACL entries (default is 4)*/
   level_t  st_level;			/* unused */
   unsigned long  st_flags;		/* contains MOUNTED flag*/

   int	st_aclcnt;	/* Number of ACL entries */
   lid_t	st_level;	/* unused */
   ulong   st_flags;	/* contains MOUNTED flag */

+
This data type is a 32 bit/64 bit switchable data type. See ``Large File Support'' on intro(2) for information on Large File Support (LFS).


st_dev
This field uniquely identifies the file system that contains the file. Its value may be used as input to the ustat(2) system call to determine more information about this file system. No other meaning is associated with this value.

st_ino
This field uniquely identifies the file in a given file system. The pair st_ino and st_dev uniquely identify regular files.

st_mode
The mode of the file as described in mknod(1M). In addition to the modes described in mknod(1M), the mode of a file may also be S_IFLNK if the file is a symbolic link. (Note that S_IFLNK may only be returned by lstat.)

st_nlink
This field should be used only by administrative commands.

st_uid
The user ID of the file's owner.

st_gid
The group ID of the file's group.

st_rdev
This field should be used only by administrative commands. It is valid only for block special or character special files and only has meaning on the system where the file was configured.

st_size
For regular files, this is the address of the end of the file. Defined for block devices, although the size may be zero if the device size is unknown. See also pipe(2).

st_atime
Time when file data was last accessed. Changed by the following system calls: creat(2), mknod(2), pipe, utime(2), and read(2).

st_mtime
Time when data was last modified. Changed by the following system calls: creat, mknod, pipe, utime, and write(2).

st_ctime
Time when file status was last changed. Changed by the following system calls: chmod(2), chown(2), creat, link(2), mknod(2), pipe, unlink, utime(2), and write.

st_blksize
A hint as to the ``best'' unit size for I/O operations. This field is not defined for block-special or character-special files.

st_blocks
The total number of physical blocks of size 512 bytes actually allocated on disk. This field is not defined for block-special or character-special files. A file residing on an s5 filesystem reports number of blocks allocated assuming no holes in the file.

st_fstype
The name of the filesystem type.

st_aclcnt
The total number of entries in the file's Access Control List. This includes the 4 basic entries (owner, group, class, other) as well as extended ACL entries.

st_level
Currently unused.

st_aclcnt
The number of ACL entries (the default is 4).


st_level
Currently unused.

st_flags
_S_ISMOUNTED indicates that path is a block or character special file that contains a mounted file system. This flag is reserved for use by administrative commands and is not intended for general application use.

The constants used in the st_mode field are also defined in this file:

   #define	S_IFMT	/* type of file */
   #define	S_IAMB	/* access mode bits */
   #define	S_IFIFO	/* fifo */
   #define	S_IFCHR	/* character special */
   #define	S_IFDIR	/* directory */
   #define	S_IFNAM	/* obsolete XENIX special named file */
   #define	S_INSEM	/* obsolete XENIX semaphore subtype of IFNAM */
   #define	S_INSHD	/* obsolete XENIX shared data subtype of IFNAM */
   #define	S_IFBLK	/* block special */
   #define	S_IFREG	/* regular */
   #define	S_IFLNK	/* symbolic link */
   #define	S_ISUID	/* set user id on execution */
   #define	S_ISGID	/* set group id on execution */
   #define	S_ISVTX	/* save swapped text even after use */
   #define	S_IREAD	/* read permission, owner */
   #define	S_IWRITE	/* write permission, owner */
   #define	S_IEXEC	/* execute/search permission, owner */
   #define	S_ENFMT	/* record locking enforcement flag */
   #define	S_IRWXU	/* read, write, execute: owner */
   #define	S_IRUSR	/* read permission: owner */
   #define	S_IWUSR	/* write permission: owner */
   #define	S_IXUSR	/* execute permission: owner */
   #define	S_IRWXG	/* read, write, execute: group */
   #define	S_IRGRP	/* read permission: group */
   #define	S_IWGRP	/* write permission: group */
   #define	S_IXGRP	/* execute permission: group */
   #define	S_IRWXO	/* read, write, execute: other */
   #define	S_IROTH	/* read permission: other */
   #define	S_IWOTH	/* write permission: other */
   #define	S_IXOTH	/* execute permission: other */

The following macros are for POSIX conformance:

   #define   S_ISBLK(mode)	/* block special file */
   #define   S_ISCHR(mode)	/* character special file */
   #define   S_ISDIR(mode)	/* directory file */
   #define   S_ISFIFO(mode)	/* pipe or fifo file */
   #define   S_ISREG(mode)	/* regular file */

References

stat(2), stat64(2), types(5)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004