|
|
1.1 ! root 1: .TH STAT 2 ! 2: .CT 2 file_inq_creat ! 3: .SH NAME ! 4: stat, lstat, fstat \(mi get file status ! 5: .SH SYNOPSIS ! 6: .nf ! 7: .B #include <sys/types.h> ! 8: .B #include <sys/stat.h> ! 9: .PP ! 10: .B int stat(name, buf) ! 11: .B char *name; ! 12: .B struct stat *buf; ! 13: .PP ! 14: .B int lstat(name, buf) ! 15: .B char *name; ! 16: .B struct stat *buf; ! 17: .PP ! 18: .B int fstat(fildes, buf) ! 19: .B struct stat *buf; ! 20: .fi ! 21: .SH DESCRIPTION ! 22: .I Stat ! 23: puts detailed information about the file ! 24: .I name ! 25: in a structure whose address is ! 26: .IR buf . ! 27: .I Lstat ! 28: does the same except that when ! 29: .I name ! 30: is a symbolic ! 31: link (see ! 32: .IR link (2)), ! 33: it ! 34: supplies information about the link itself. ! 35: .I Fstat ! 36: does what ! 37: .I stat ! 38: does for the file open on descriptor ! 39: .IR fildes . ! 40: .PP ! 41: It is unnecessary to have any ! 42: permissions at all with respect to ! 43: .IR name , ! 44: but all directories ! 45: leading to the file must be searchable. ! 46: .nf ! 47: .ta \w'\fLnnnnnnnn\fP'u +\w'\fLunsigned short st_mode; \fP'u ! 48: \fLstruct stat ! 49: { ! 50: \fLdev_t st_dev;\fR device number for this file system ! 51: \fLino_t st_ino;\fP inode number ! 52: \fLunsigned short st_mode;\fP file mode encoded as below ! 53: \fLshort st_nlink;\fP number of links (not symbolic links) ! 54: \fLshort st_uid;\fP uid of owner ! 55: \fLshort st_gid;\fP gid of owner ! 56: \fLdev_t st_rdev;\fP if device file, the device number ! 57: \fLoff_t st_size;\fP size in bytes ! 58: \fLtime_t st_atime;\fP time file was last read or created ! 59: \fLtime_t st_mtime;\fP time file was last written or created ! 60: \fLtime_t st_ctime;\fP time file or inode was last written or created ! 61: \fL};\fP ! 62: .fi ! 63: .PP ! 64: The bits in ! 65: .B st_mode ! 66: are defined by ! 67: .nf ! 68: .ft L ! 69: .ta 10n 20n ! 70: .ft P ! 71: \fLS_IFMT 0170000\fP file type ! 72: \fLS_IFDIR 0040000\fP directory ! 73: \fLS_IFCHR 0020000\fP character device ! 74: \fLS_IFBLK 0060000\fP block device ! 75: \fLS_IFREG 0100000\fP regular file ! 76: \fLS_IFLNK 0120000\fP symbolic link ! 77: \fLS_ISUID 0004000\fP set userid on execution ! 78: \fLS_ISGID 0002000\fP set groupid on execution ! 79: \fLS_ICCTYP 0007000\fP type of concurrency control ! 80: \fLS_ISYNC 0001000\fP 1 writer and n readers (synchronized access) ! 81: \fLS_IEXCL 0003000\fP 1 writer or n readers (exclusive access) ! 82: \fL 0000400\fP read permission by owner ! 83: \fL 0000200\fP write permission by owner ! 84: \fL 0000100\fP execute permission (search on directory) by owner ! 85: \fL 0000070\fP read, write, execute (search) by group ! 86: \fL 0000007\fP read, write, execute (search) by others ! 87: .fi ! 88: .PP ! 89: .B S_IFMT ! 90: and ! 91: .B S_ICCTYP ! 92: are field masks; the other constants encode modes. ! 93: Codes contained in the ! 94: .B S_IFMT ! 95: field are mutually exclusive. ! 96: If bit ! 97: .L 01000 ! 98: is set, ! 99: the concurrency modes contained in ! 100: .B S_ICCTYP ! 101: are in effect; ! 102: otherwise the set-id flags ! 103: .B S_ISUID ! 104: and ! 105: .B S_ISGID ! 106: apply. ! 107: .PP ! 108: The concurrency modes affect ! 109: .I open ! 110: and ! 111: .I creat ! 112: calls. ! 113: Synchronized access, ! 114: .BI S_ISYNC , ! 115: guards against inconsistent updates ! 116: by forbidding concurrent opens for writing. ! 117: Exclusive access, ! 118: .BI S_IEXCL , ! 119: guards against inconsistent views ! 120: by forbidding concurrent opens if one is for writing. ! 121: .SH "SEE ALSO" ! 122: .IR chmod (1), ! 123: .IR ls (1), ! 124: .IR chmod (2), ! 125: .IR filsys (5) ! 126: .SH DIAGNOSTICS ! 127: .IR stat , ! 128: .IR lstat : ! 129: .BR EACCES , ! 130: .BR EFAULT , ! 131: .BR EIO , ! 132: .BR ELOOP , ! 133: .BR ENOENT , ! 134: .BR ENOTDIR ! 135: .br ! 136: .IR fstat : ! 137: .BR EBADF , ! 138: .BR EFAULT , ! 139: .BR EIO ! 140: .SH BUGS ! 141: For efficiency, ! 142: .B st_atime ! 143: is not set when a directory ! 144: is searched, although this might be more logical.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.