3 stat, fstat, wstat, fwstat, dirstat, dirfstat, dirwstat, dirfwstat, nulldir \- get and put file status
10 int stat(char *name, uchar *edir, int nedir)
13 int fstat(int fd, uchar *edir, int nedir)
16 int wstat(char *name, uchar *edir, int nedir)
19 int fwstat(int fd, uchar *edir, int nedir)
22 Dir* dirstat(char *name)
28 int dirwstat(char *name, Dir *dir)
31 int dirfwstat(int fd, Dir *dir)
38 or an open file descriptor
40 these routines retrieve or modify file status information.
46 are the system calls; they deal with machine-independent
47 .IR "directory entries" .
48 Their format is defined by
53 retrieve information about
66 write information back, thus changing file attributes according to the contents of
68 The data returned from the kernel includes its leading 16-bit length field
71 For symmetry, this field must also be present when passing data to the kernel in a call to
75 but its value is ignored.
82 are similar to their counterparts, except that they
88 .ta 6n +\w'ulong 'u +\w'mtime; 'u
91 /* system-modified data */
92 uint type; /* server type */
93 uint dev; /* server subtype */
95 Qid qid; /* unique id from server */
96 ulong mode; /* permissions */
97 ulong atime; /* last read time */
98 ulong mtime; /* last write time */
99 vlong length; /* file length: see <u.h> */
100 char *name; /* last element of path */
101 char *uid; /* owner name */
102 char *gid; /* group name */
103 char *muid; /* last modifier name */
107 The returned structure is allocated by
109 freeing it also frees the associated strings.
117 If the file resides on permanent storage and is not a directory,
118 the length returned by
120 is the number of bytes in the file.
121 For directories, the length returned is zero.
122 For files that are streams (e.g., pipes and network connections),
123 the length is the number of bytes that can be read without blocking.
125 Each file is the responsibility of some
127 it could be a file server, a kernel device, or a user process.
129 identifies the server type, and
131 says which of a group of servers of the same type is the one
132 responsible for this file.
134 is a structure containing
141 unique among all path names currently on the file server, and
143 changes each time the file is modified.
157 Thus, if two files have the same
162 they are the same file.
168 .ta 6n +\w'\fL0x80000000 'u
170 \fL 0x80000000\fP directory
171 \fL 0x40000000\fP append only
172 \fL 0x20000000\fP exclusive use (locked)
173 \fL 0x00800000\fP Unix device file
174 \fL 0x00400000\fP symbolic link
175 \fL 0x00200000\fP named pipe
176 \fL 0x00100000\fP socket
178 \fL 0400\fP read permission by owner
179 \fL 0200\fP write permission by owner
180 \fL 0100\fP execute permission (search on directory) by owner
181 \fL 0070\fP read, write, execute (search) by group
182 \fL 0007\fP read, write, execute (search) by others
185 There are constants defined in
192 for the first three; and
197 for the read, write, and execute bits for others.
199 The two time fields are measured in seconds since the epoch
200 (Jan 1 00:00 1970 GMT).
202 is the time of the last change of content.
205 is set whenever the contents are accessed;
206 also, it is set whenever
213 are the names of the owner and group of the file;
215 is the name of the user that last modified the file (setting
217 Groups are also users, but each server is free to associate
218 a list of users with any user name
221 set of users in the group
223 When an initial attachment is made to a server,
224 the user string in the process group is communicated to the server.
225 Thus, the server knows, for any given file access, whether the accessing
226 process is the owner of, or in the group of, the file.
227 This selects which sets of three bits in
229 is used to check permissions.
231 Only some of the fields may be changed with the
236 can be changed by anyone with write permission in the parent directory.
241 can be changed by the owner or the group leader of the file's current
245 can be changed: by the owner if also a member of the new group; or
246 by the group leader of the file's current group
247 if also leader of the new group
250 for more information about permissions, users, and groups).
253 can be changed by anyone with write permission, provided the operation
254 is implemented by the server.
257 for permission, user, and group information).
259 Special values in the fields of the
263 indicate that the field is not intended to be changed by the call.
264 The values are the maximum unsigned integer of appropriate size
265 for integral values (usually
267 but beware of conversions and size mismatches
268 when comparing values) and the empty or nil string for string values.
271 initializes all the elements of
273 to these ``don't care'' values.
274 Thus one may change the mode, for example, by using
278 then setting the mode, and then doing
280 it is not necessary to use
282 to retrieve the initial values first.
284 .B \*9/src/lib9/dirstat.c
293 functions return a pointer to the data for a successful call, or
297 return the number of bytes copied on success, or \-1 on error.
305 is too short for the returned data, the return value will be
310 returned will contain the initial count field of the
317 (for the count itself) should succeed.