Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ open.bsd(2) — Domain/IX SR9.2.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

OPEN(2)

NAME

open − open a file for reading or writing, or create a new file

USAGE

#include <sys/file.h>

open(path, flags, mode)
char *path;
int flags, mode;

DESCRIPTION

Open opens the file named by path for reading and/or writing, as specified by the flags argument and returns a descriptor for that file.  The flags argument may indicate that the file is to be created if it does not already exist (the O_CREAT flag).  In this case, the file is created with mode mode, as described in chmod(2) and as modified by the process’ umask value (see umask(2)). 

Path is the address of a string of ASCII characters representing a pathname, terminated by a null character.  The flags are formed from the logical or of the following values:

O_RDONLYopen for reading only
O_WRONLYopen for writing only
O_RDWRopen for reading and writing
O_NDELAYdo not block on open
O_APPENDappend on each write
O_CREATcreate file if it does not exist
O_TRUNCtruncate size to zero
O_EXCLerror if create and file exists

Opening a file with O_APPEND set causes each write on the file to be appended to the end.  If O_TRUNC is specified and the file exists, the file is truncated to zero length.  If O_EXCL is set with O_CREAT and the file already exists, the open returns an error.  This can be used to implement a simple exclusive access locking mechanism.  If the O_NDELAY flag is specified and the o

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026