[Top] [Prev] [Next]

stat, fstat, fwstat, wstat - get and put file status

include "sys.m";
sys:= load Sys Sys->PATH;
fstat:  fn(fd: ref FD)          : (int, Dir);
fwstat: fn(fd: ref FD;  d: Dir) : int;
stat:   fn(name: string)        : (int, Dir);
wstat:  fn(name: string, d: Dir): int;


stat (name, d) and fstat (fd, d)

Given a file's name, or an open file descriptor fd, these routines return information about the file into the Dir member of the returned tuple. The int member will be zero for success and -1 for failure.

wstat (name, d) and fwstat (fd, d)

The wstat and fwstat functions apply the file attributes of d to the file. Only certain attributes can be modified. See the section Modifying File Attributes. Both functions return zero for success and -1 for failure.

The Dir Abstract Data Type

File status is managed via the Dir abstract data type:

Qid: adt 
	path:  int;   
	vers:  int; 

Dir: adt 
	name:   string;   
	uid:    string;   
	gid:    string;   
	qid:    Qid;   
	mode:   int;   
	atime:  int;   
	mtime:  int;   
	length: int;   
	dtype:  int;   
	dev:    int; 

File Mode Bits

Directory. The Sys module defines this as CHDIR.


Read permission by owner.


Write permission by owner.


Execute permission (search on directory) by owner


Read, write, execute (search) by group.


Read, write, execute (search) by others.

Modifying File Attributes

Only some of the fields may be changed by wstat calls.

The name can be changed by anyone with write permission in the parent directory.

mode and mtime

The mode and mtime can be changed by the owner or the group leader of the file's current group.


The gid can be changed by the owner.

See Also
Limbo System Module

dirread - read directory

open, create - open/create a file for reading or writing

stat, wstat - inquire or change file attributes in Chapter 3


The following behaviors apply when Inferno is hosted on Windows-based systems.

FAT File system (Win95 and Windows-NT)

The values of uid and gid are Everyone.

Files and directories always have read and execute permission. They cannot be changed. Files without write permission cannot be removed.

NTFS File system (Windows-NT)

Permissions for read, write, and execute operate as described above.

The uid attribute is supported.

The gid attribute is interpreted always to mean the special group InfernoGroup, even if the underlying Windows system maintains other groups for the file. Special group Everyone is used to represent 'other' for permissions.

[Top] [Prev] [Next]

Copyright © 1996,Lucent Technologies, Inc. All rights reserved.