Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
SysStat


NAME

SysStat - examine inode structure

SYNOPSIS

CONST type = {16..19};
CONST prot = {23..31};


(* file types *) CONST reg = {16}; (* regular *) CONST dir = {17}; (* directory *) CONST chr = {18}; (* character special *) CONST fifo = {19}; (* fifo *) CONST blk = {17..18}; (* block special *) CONST symlink = {16, 18}; (* symbolic link *) CONST socket = {16, 17}; (* socket *) CONST door = {16, 17, 19}; (* door *)

(* special *) CONST setuid = 20; (* set user id on execution *) CONST setgid = 21; (* set group id on execution *) CONST savetext = 22; (* save swapped text even after use *)

(* protection *) CONST uread = 23; (* read permission owner *) CONST uwrite = 24; (* write permission owner *) CONST uexec = 25; (* execute/search permission owner *) CONST gread = 26; (* read permission group *) CONST gwrite = 27; (* write permission group *) CONST gexec = 28; (* execute/search permission group *) CONST oread = 29; (* read permission other *) CONST owrite = 30; (* write permission other *) CONST oexec = 31; (* execute/search permission other *)

CONST owner = {23..25}; CONST group = {26..28}; CONST other = {29..31}; CONST read = {23, 26, 29}; CONST write = {24, 27, 30}; CONST exec = {25, 28, 31}; CONST rwx = {23..31};

TYPE StatRec = RECORD device: SysTypes.Device; (* ID of device containing a directory entry for this file *) inode: SysTypes.Inode; (* inode number *) mode: SET; (* file mode; see mknod(2) *) nlinks: INTEGER; (* number of links *) uid: INTEGER; (* user id of the file's owner *) gid: INTEGER; (* group id of the file's group *) rdev: SysTypes.Device; (* ID of device this entry is defined only for character special or block special files *) size: SysTypes.Offset; (* file size in bytes *) atime: SysTypes.Time; (* time of last access *) mtime: SysTypes.Time; (* time of last data modification *) ctime: SysTypes.Time; (* time of last file status change *) blksize: LONGINT; (* preferred blocksize *) blocks: LONGINT; (* # of blocks allocated *) END;

PROCEDURE Stat(path: ARRAY OF CHAR; VAR buf: StatRec; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Lstat(path: ARRAY OF CHAR; VAR buf: StatRec; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Fstat(fd: SysTypes.File; VAR buf: StatRec; errors: RelatedEvents.Object) : BOOLEAN;

DESCRIPTION

Stat, Lstat, and Fstat interface the stat, lstat, and fstat UNIX system calls. All return the status information in buf, a record of type StatRec.

The protection bits are defined for Oberon in a convenient manner. The low-order 2-byte-word of mode determines the type and protection of the file. type specifies the mask for the file type and prot the mask for the protection.

Possible file types are:

reg
regular file
dir
directory
chr
character special
fifo
named pipe
blk
block special
symlink
link
socket
socket file
Example: Check stat to represent a directory: stat.mode * SysStat.type = SysStat.dir.

The file protection includes some special bits:

setuid
set user id on execution
setgid
set group id on execution
savetext
save swapped text even after use
and regular protection bits: uread, uwrite, uexec, gread, gwrite, gexec, oread, owrite, and oexec. These bits are given by their bit number. Example for "rw-r--r--": {uread, uwrite, gread, oread}.

Additional masks are given for owner, group, other, read, write, exec, and rwx. owner includes all bits dedicated to the owner, read includes bits for reading (owner, group, and others), rwx contains all regular protection bits. Example for "rw-r--r--": (SysStat.read+SysStat.write)*SysStat.owner + SysStat.read*(SysStat.group+SysStat.other).

DIAGNOSTICS

System call failures lead to events of SysErrors. The errors parameter is passed to SysErrors.Raise. Both procedures return FALSE in error case.

SEE ALSO

stat(2)
stat and fstat system call
SysErrors
handling of system call failures
SysTypes
types needed for system calls

BUGS

Some UNIX versions have less file types (e.g. symlink and socket) and no additional meanings for special bits (i.e. for directories).
Edited by: borchert, last change: 2000/11/12, revision: 1.1.2.4, converted to HTML: 2000/11/12

Oberon || Library || Module Index || Search Engine || Definition || Module