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)
174 \fL 0400\fP read permission by owner
175 \fL 0200\fP write permission by owner
176 \fL 0100\fP execute permission (search on directory) by owner
177 \fL 0070\fP read, write, execute (search) by group
178 \fL 0007\fP read, write, execute (search) by others
181 There are constants defined in
188 for the first three; and
193 for the read, write, and execute bits for others.
195 The two time fields are measured in seconds since the epoch
196 (Jan 1 00:00 1970 GMT).
198 is the time of the last change of content.
201 is set whenever the contents are accessed;
202 also, it is set whenever
209 are the names of the owner and group of the file;
211 is the name of the user that last modified the file (setting
213 Groups are also users, but each server is free to associate
214 a list of users with any user name
217 set of users in the group
219 When an initial attachment is made to a server,
220 the user string in the process group is communicated to the server.
221 Thus, the server knows, for any given file access, whether the accessing
222 process is the owner of, or in the group of, the file.
223 This selects which sets of three bits in
225 is used to check permissions.
227 Only some of the fields may be changed with the
232 can be changed by anyone with write permission in the parent directory.
237 can be changed by the owner or the group leader of the file's current
241 can be changed: by the owner if also a member of the new group; or
242 by the group leader of the file's current group
243 if also leader of the new group
246 for more information about permissions and
248 for users and groups).
251 can be changed by anyone with write permission, provided the operation
252 is implemented by the server.
255 for permission information, and
257 for 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 .TF /sys/src/libc/9syscall
286 .B /sys/src/libc/9syscall
291 .B /sys/src/libc/9sys
292 for the routines prefixed
302 functions return a pointer to the data for a successful call, or
306 return the number of bytes copied on success, or \-1 on error.
314 is too short for the returned data, the return value will be
319 returned will contain the initial count field of the
326 (for the count itself) should succeed.