open - open for reading or writing


#include <stdio_p.h>
#include <fcntl_p.h>

FD open(path, oflag[, mode])
char *path;
int oflag, mode;


path points to a path name naming a file on either the satellite system or the host system (host path names are preceded with a '!'). Some path names are reserved to open the local device drivers on the satellite. A list of possible reserved names (depending on how the satellite is configured) includes:

serial lines

programmable clock

analog to digital converter

digital to analog converter

packet driver

smpte time code

RL02 disk

visual display

display clock

high current digital output

digit input and output

16-bit input buffer

See section 4 for a description of the function of these special files.

open opens a file descriptor for the named file and sets the file status flags according to the value of oflag. oflag values are constructed by ORing flags from the following list:

Choose 1 from the next 3 permission flags.

Open for reading only.

Open for writing only.

Open for reading and writing.

If set, the file pointer will be set to the end of the file before the first write.

If the file exists, this flag has no effect. If path refers to a host file, this file's owner ID is set to the process's effective user ID, the file's group ID is set to the process's effective group ID, and the low-order 12 bits of the file mode are set to the value of mode modified by ORing together some combination of the following:

04000 set user ID on execution
02000 set groupo ID on execution
01000 save text image after execution
00400 read by owner
00200 write by owner
00100 execute (search on directory) by owner
00070 read, write, execute (search) by group
00007 read, write, execute (search) by others

If path refers to a satellite file, only the read/write/execute by owner fields of mode are used.

If the file exists, its length is truncated to 0 and the mode and owner are unchanged.

If O_EXCL and O_CREAT are set, open will faile if the file exists.

Upon successful completions a non-negative integer, the file descriptor, is returned.

The file pointer used to mark the current position within the file is set to the beginning of the file, unless O_APPEND is set, in which case the file pointer is set to the end of the file.

No process may have more than 20 host files or 10 satellite files open simultaneously. Any number of special satellite devices may be open at once.

The named file is opened unless one or more of the following are true:


Upon successful completion, a non-negative integer, namely a file descriptor, is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.


close(2P) , lseek(2P) , read(2P) , write(2P).