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


Ulm's Oberon Library:
SysFile


NAME

SysFile - system calls related to files

SYNOPSIS

CONST readAccess = {SysStat.oread};
CONST writeAccess = {SysStat.owrite};
CONST execAccess = {SysStat.oexec};
CONST existence = {};


TYPE AccessMode = SET;

PROCEDURE Access(filename: ARRAY OF CHAR; amode: AccessMode; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE EffectiveAccess(filename: ARRAY OF CHAR; amode: AccessMode; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE Link(filename1, filename2: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Unlink(filename: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Rename(filename1, filename2: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE SymbolicLink(VAR filename1, filename2: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE ReadLink(filename: ARRAY OF CHAR; VAR buf: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE MakeDir(filename: ARRAY OF CHAR; mode: SET; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE RemoveDir(filename: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE SetFileCreationMask(mask: SET; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE GetFileCreationMask(VAR mask: SET; errors: RelatedEvents.Object) : BOOLEAN;

DESCRIPTION

SysFiles interfaces system calls which are related to files. Input- and output operations are covered by SysIO.

Access is mapped to access(2) and checks filename to be accessible with mode amode for the real user id of the process.

Typically, effective and real user id only differ for processes which have been started as s-bit commands (s-bit stands for substitute user bit and is part of the file attributes). In these cases the effective user id equals the owner of the command file and the real user id is inherited from the parent process. While in all other system calls accesses are checked against the effective user id, this system calls allows to check accessibility for the real user id of the parent process.

EffectiveAccess works like Access but checks the accessibility for the calling process by considering the effective user id.

Link creates a new directory entry named filename2 which points to the file referenced by filename1. Both file references must belong to the same file system. Unlink removes the directory entry named filename. The disc space allocated by the referenced file is reclaimed by the operating system if filename was the last reference to the referenced file. Rename works for files and directories where both pathnames reside on the same file system. A new link named filename2 is created and the old link named filename1 is removed, just like a combination of Link and Unlink that, however, would not work for directories.

SymbolicLink creates a new symbolic link named filename2 that points to filename1 which is not required to exist and may point to other file systems. Chains of symbolic links are permitted up to a system-dependent maximum level of indirection. ReadLink allows to read out the pathname a symbolic link points to.

MakeDir creates a new directory with mode mode (see SysStat) that is matched against the umask. RemoveDir allows to remove empty directories.

SetFileCreationMask and GetFileCreationMask set/get the umask of the current process. The complement of the umask is ANDed against the protection mode of newly created files or directories to yield the effective protection mode. The umask is inherited to child processes.

DIAGNOSTICS

System call failures lead to events of SysErrors. The errors parameter is passed to SysErrors.Raise. All procedures return FALSE in error case. Access test failures of Access and EffectiveAccess are interpreted as system call failures.

SEE ALSO

access(2)
Access, EffectiveAccess
link(2)
Link
mkdir(2)
MakeDir
readlink(2)
ReadLink
rename(2)
Rename
rmdir(2)
RemoveDir
stat(2)
EffectiveAccess
symlink(2)
SymbolicLink
umask(2)
SetFileCreationMask, GetFileCreationMask
unlink(2)
Unlink
SysErrors
handling of failed system calls
SysIO
opening, accessing and closing a file
SysStat
retrieval of file attributes

Edited by: borchert, last change: 2000/12/11, revision: 1.7, converted to HTML: 2000/12/11

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