Oberon || Library || Module Index || Search Engine || Definition || Module
(* file control options: arguments of Fcntl and Open *) CONST rdonly = {}; CONST wronly = { 31 }; CONST rdwr = { 30 }; CONST ndelay = { 29 }; CONST append = { 28 }; CONST creat = { 23 }; CONST trunc = { 22 }; CONST excl = { 21 };
(* Whence = (fromStart, fromPos, fromEnd); *) CONST fromStart = 0; CONST fromPos = 1; CONST fromEnd = 2;
(* file descriptor flags *) CONST closeonexec = { 31 };
(* Fcntl requests *) CONST dupfd = 0; CONST getfd = 1; CONST setfd = 2; CONST getfl = 3; CONST setfl = 4; CONST getlk = 5; CONST setlk = 6; CONST setlkw = 7;
TYPE File = SysTypes.File; TYPE Address = SysTypes.Address; TYPE Count = SysTypes.Count; TYPE Protection = INTEGER; TYPE Whence = INTEGER;
PROCEDURE Open(VAR fd: File; filename: ARRAY OF CHAR; options: SET; errors: RelatedEvents.Object; retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; PROCEDURE OpenCreat(VAR fd: File; filename: ARRAY OF CHAR; options: SET; protection: Protection; errors: RelatedEvents.Object; retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; PROCEDURE Close(fd: File; errors: RelatedEvents.Object; retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; PROCEDURE Read(fd: File; buf: Address; cnt: Count; errors: RelatedEvents.Object; retry: BOOLEAN; VAR interrupted: BOOLEAN) : Count; PROCEDURE Write(fd: File; buf: Address; cnt: Count; errors: RelatedEvents.Object; retry: BOOLEAN; VAR interrupted: BOOLEAN) : Count; PROCEDURE Seek(fd: File; offset: Count; whence: Whence; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Tell(fd: File; VAR offset: Count; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Isatty(fd: File) : BOOLEAN; PROCEDURE Dup(fd: File; VAR newfd: File; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Dup2(fd, newfd: File; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Fcntl(fd: File; request: INTEGER; VAR arg: INTEGER; errors: RelatedEvents.Object; retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; PROCEDURE FcntlSet(fd: File; request: INTEGER; flags: SET; errors: RelatedEvents.Object; retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; PROCEDURE FcntlGet(fd: File; request: INTEGER; VAR flags: SET; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Pipe(VAR readfd, writefd: File; errors: RelatedEvents.Object) : BOOLEAN;
File represents file descriptors which serve as handle for input and output on system call level and are small integers.
The open(2) system calls has two or three parameters. The third parameter is needed in case of file creation to specify the file protection. File creation is indicated by or-ing creat to options. Open and OpenCreat open filename (must be 0X-terminated) under the control of options:
Isatty tests fd for being associated to a terminal device. This is done by an ioctl(2) system call. Isatty does not generate any events.
Dup and Dup2 realize the equally named system calls of UNIX Edition VII and Berkeley Systems. They are replaced by fcntl(2) on UNIX System V systems but are supported by SysIO for portability. Dup returns a new file descriptor in newfd which is a synomym for fd (i.e. both point to the same entry of the open file table). Dup2 works like Dup but causes newfd to be the synonym. If newfd was opened it is closed first.
Fcntl implements the equally named system call. FcntlSet and FcntlGet are more convenient interfaces to Fcntl. Following requests are supported:
Close, Read, Write, Seek, Tell, and Pipe realize the equally named system calls. Valid values of the whence parameter of Seek are
Some of the system calls may be interrupted. In normal case (retry = FALSE) this causes the appropiate error event to be raised (error code SysErrors.intr) and the system call to be aborted. If retry is TRUE, the system call will be repeated until no interrupt occured. interrupt indicates in both cases whether interrupts occured or not.
Oberon || Library || Module Index || Search Engine || Definition || Module