[Top] [Prev] [Next]

stat

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

Synopsis

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;

Description

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 section the section titled Modifying File Attributes below. 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
16r80000000

Directory. The Sys module defines this as Sys->CHDIR.

8r400

Read permission by owner.

8r200

Write permission by owner.

8r100

Execute permission (search on directory) by owner

8r070

Read, write, execute (search) by group.

8r007

Read, write, execute (search) by others.

Modifying File Attributes

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

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.

gid

The gid can be changed by the owner.

See Also

Limbo System Modules, dirread, open, and stat

Notes

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]

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