[Top] [Prev] [Next]

stat

stat, wstat - inquire or change file attributes

Synopsis

Tstat  tag [2] fid [2]
Rstat  tag [2] fid [2] stat [116]
Twstat tag [2] fid [2] stat [116]
Rwstat tag [2] fid [2]

Description

The stat Transaction

The stat transaction inquires about the file identified by fid. The reply includes (in the stat argument) a directory entry containing the file's attributes.

The stat request requires no special permissions other than those needed to acquire fid.

Directory Entry Layout

Both the stat and wstat messages transmit file attributes in a machine-independent representation called a directory entry.

A directory entry is 116-bytes long. See DIRLEN in <lib9.h>. Integers in this encoding are in little-endian order (least significant byte first). The convM2D and convD2M routines (see styx) convert between directory entries and C language structures.

This encoding may be turned into a machine dependent Dir structure (see <lib9.h>) using routines defined in styx.

A directory entry is laid out as follows:
name [28]

File name. If the file is the root directory of the server the name must be /.

uid [28]

Owner name.

gid [28]

Group name.

qid.path [4]

File server's identification for the file. See Inferno File Protocol, Styx.

qid.vers [4]

Version number for given path. See Inferno File Protocol, Styx.

mode [4]

Permissions and flags. The mode contains permission bits as described in Inferno Devices and 16r80000000 if this file is a directory.

atime [4]

The last access time. The atime field records the last read of the contents; it is also set whenever mtime is set.

For a directory, atime is set by an attach, walk, or create, all whether successful or not.

The value is measured in seconds since the epoch (Jan 1 00:00 1970 GMT).

mtime [4]

The last modification time. The mtime field reflects the time of the last change of content.

For a plain file, mtime is the time of the most recent create, open with truncation, or write; for a directory it is the time of the most recent remove, create, or wstat of a file in the directory.

The value is measured in seconds since the epoch

(Jan 1 00:00 1970 GMT).

length [8]

Length of file in bytes. Directories and most files representing devices have, by convention, a length of 0.

type [2]

See discussion of devtype in Inferno File Protocol, Styx.

dev [2]

See discussion of dev in Inferno File Protocol, Styx.

A read of a directory yields an integral number of directory entries in the machine independent encoding given above (see read).

The wstat Transaction

The wstat request can change certain file attributes.
name

The name can be changed by anyone with write permission in the parent directory. It is an error to change the name of a file to that of an existing file.

mode and mtime

The mode and mtime can be changed by the owner of the file. The directory bit cannot be changed by a wstat. All the other defined permission and mode bits can be change.

gid

The gid can be changed: by the owner if also a member of the new group. (See Inferno File Protocol, Styx for more information about permissions and users for users and groups).

None of the other attributes can be altered by a wstat. In particular, there is no way to change the owner of a file.

Entry Points

Type stat messages are generated by the fstat and stat calls (see stat).

See Also

styx, stat, Inferno File Protocol, Styx, and read



[Top] [Prev] [Next]

infernosupport@lucent.com
Copyright © 1996,Lucent Technologies, Inc. All rights reserved.