stat, wstat – inquire or change file attributes
transaction inquires about the file
The reply will contain a
laid out as follows:
total byte count of the following data
for kernel use
for kernel use
the type of the file (directory, etc.), represented as a bit vector
corresponding to the high 8 bits of the file’s mode word.
version number for given path
the file server’s unique identification for the file
permissions and flags
last access time
last modification time
length of file in bytes
name[ s ]
file name; must be
if the file is the root directory of the server
uid[ s ]
gid[ s ]
muid[ s ]
name of the user who last modified the file
Integers in this encoding are in little-endian order (least
significant byte first).
convert between directory entries and a C structure called a
contains permission bits as described in
and the following:
this file is a directory),
these are echoed in
Writes to append-only files always place their data at the
end of the file; the
message is ignored, as is the
bit in an open.
Exclusive use files may be open for I/O by only one fid at a time
across all clients of the server. If a second open is attempted,
it draws an error. Servers may implement a timeout on the lock
on an exclusive use file: if the fid holding the file open has
been unused for an extended period (of order at least minutes),
it is reasonable to break the lock and deny the initial fid
Temporary files are not included in nightly archives.
The two time fields are measured in seconds since the epoch
(Jan 1 00:00 1970 GMT).
field reflects the time of the last change of content (except when later changed by
For a plain file,
is the time of the most recent
for a directory it is the time of the most recent
of a file in the directory.
field records the last
of the contents;
also it is set whenever
In addition, for a directory, it is set by
all whether successful or not.
field names the user whose actions most recently changed the
of the file.
records the number of bytes in the file.
Directories and most files representing devices have a conventional
length of 0.
request requires no special permissions.
request can change some of the file status information.
can be changed by anyone with write permission in the parent directory;
it is an error to change the name to that of an existing file.
can be changed (affecting the actual length of the file) by anyone with
write permission on the file.
It is an error to attempt to set the length of a directory to a non-zero value,
and servers may decide to reject length changes for other reasons.
can be changed by the owner of the file or the group leader of the file’s current
The directory bit cannot be changed by a
the other defined permission and mode bits can.
can be changed: by the owner if also a member of the new group; or
by the group leader of the file’s current group
if also leader of the new group
for more information about permissions and
for users and groups).
None of the other data can be altered by a
and attempts to change them will trigger an error.
it is illegal to attempt to change the owner of a file.
(These conditions may be
relaxed when establishing the initial state of a file server; see
Either all the changes in
request happen, or none of them does: if the request succeeds,
all changes were made; if it fails, none were.
request can avoid modifying some properties of the file
by providing explicit “don’t touch” values in the
data that is sent: zero-length strings for text values and
the maximum unsigned value of appropriate size
for integral values.
As a special case, if
the elements of the directory entry in a
message are “don’t touch” values, the server may interpret it
as a request to guarantee that the contents of the associated
file are committed to stable storage before the
message is returned.
(Consider the message to mean, “make the state of the file
exactly what it claims to be.”)
of a directory yields an integral number of directory entries in
the machine independent encoding given above
Note that since the
information is sent as a 9P variable-length datum, it is limited to a maximum of
messages are generated by
messages are generated by
To make the contents of a directory, such as returned by
easy to parse, each
directory entry begins with a size field.
For consistency, the entries in
messages also contain
their size, which means the size appears twice.
For example, the
message is formatted as
is the value returned by