STAT(II) − PWB/UNIX 8/5/73
NAME
stat − get file status
SYNOPSIS
(stat = 18.)
sys stat; name; buf stat(name, buf)
char *name;
struct inode *buf;
DESCRIPTION
Name points to a null-terminated string naming a file; buf is the address of a 36(10) byte buffer into which information is placed concerning the file. It is unnecessary to have any permissions at all with respect to the file, but all directories leading to the file must be readable. After stat, buf has the following structure (starting offset given in bytes):
struct inode {
charminor;/* +0: minor device of i-node */
charmajor;/* +1: major device */
intinumber;/* +2 */
intflags;/* +4: see below */
charnlinks;/* +6: number of links to file */
charuid;/* +7: user ID of owner */
chargid;/* +8: group ID of owner */
charsize0;/* +9: high byte of 24-bit size */
intsize1;/* +10: low word of 24-bit size */
intaddr[8];/* +12: block numbers or device number */
intactime[2];/* +28: time of last access */
intmodtime[2];/* +32: time of last modification */
};
The flags are as follows:
100000i-node is allocated
0600002-bit file type:
000000plain file
040000directory
020000character-type special file
060000block-type special file.
010000large file
004000set user-ID on execution
002000set group-ID on execution
001000save text image after execution
000400read (owner)
000200write (owner)
000100execute (owner)
000070read, write, execute (group)
000007read, write, execute (others)
SEE ALSO
DIAGNOSTICS
Error bit (c-bit) is set if the file cannot be found. From C, a −1 return indicates an error.