Commit | Line | Data |
---|---|---|
e6817382 BJ |
1 | .TH STAT 2 |
2 | .SH NAME | |
3 | stat, fstat \- get file status | |
4 | .SH SYNOPSIS | |
5 | .B #include <sys/types.h> | |
6 | .br | |
7 | .B #include <sys/stat.h> | |
8 | .PP | |
9 | .B stat(name, buf) | |
10 | .br | |
11 | .B char *name; | |
12 | .br | |
13 | .B struct stat *buf; | |
14 | .PP | |
15 | .B fstat(fildes, buf) | |
16 | .br | |
17 | .B struct stat *buf; | |
18 | .SH DESCRIPTION | |
19 | .I Stat | |
20 | obtains detailed information about a named file. | |
21 | .I Fstat | |
22 | obtains the same information about an open file | |
23 | known by the file descriptor from a successful | |
24 | .I open, creat, dup | |
25 | or | |
26 | .IR pipe (2) | |
27 | call. | |
28 | .PP | |
29 | .I Name | |
30 | points to a null-terminated string naming | |
31 | a file; | |
32 | .I buf | |
33 | is the address of a buffer | |
34 | into which information is placed concerning the file. | |
35 | It is unnecessary to have any | |
36 | permissions at all with respect to the file, but all directories | |
37 | leading to the file must be searchable. | |
38 | The layout of the structure pointed to by buf | |
39 | as defined in | |
40 | .I <stat.h> | |
41 | is given below. | |
42 | .I St_mode | |
43 | is encoded according to the `#define' statements. | |
44 | .PP | |
45 | .nf | |
46 | .so /usr/include/sys/stat.h | |
47 | .fi | |
48 | .PP | |
49 | The mode bits 0000070 and 0000007 encode group and | |
50 | others permissions (see | |
51 | .IR chmod (2)). | |
52 | The defined types, | |
53 | .I | |
54 | ino_t, off_t, time_t, | |
55 | name various width integer values; | |
56 | .I dev_t | |
57 | encodes | |
58 | major and minor device numbers; | |
59 | their exact definitions are in | |
60 | the include file <sys/types.h> | |
61 | (see | |
62 | .IR types (5). | |
63 | .PP | |
64 | When | |
65 | .I fildes | |
66 | is associated with a pipe, | |
67 | .I fstat | |
68 | reports an ordinary file with an i-node number, | |
69 | restricted permissions, | |
70 | and a not necessarily meaningful length. | |
71 | .PP | |
72 | .I st_atime | |
73 | is the file was last read. | |
74 | For reasons of efficiency, it is not set when a directory | |
75 | is searched, although this would be more logical. | |
76 | .I st_mtime | |
77 | is the time the file was last written or created. | |
78 | It is not set by changes of owner, group, link count, or mode. | |
79 | .I st_ctime | |
80 | is set both both by writing and changing the i-node. | |
81 | .SH "SEE ALSO" | |
82 | ls(1), filsys(5) | |
83 | .SH DIAGNOSTICS | |
84 | Zero is returned if a status is available; | |
85 | \-1 if the file cannot be found. | |
86 | .SH ASSEMBLER | |
87 | (stat = 18.) | |
88 | .br | |
89 | .B sys stat; name; buf | |
90 | .PP | |
91 | (fstat = 28.) | |
92 | .br | |
93 | (file descriptor in r0) | |
94 | .br | |
95 | .B sys fstat; buf |