Next: close, Up: List of Supported Calls [Contents][Index]
int open(const char *pathname, int flags); int open(const char *pathname, int flags, mode_t mode);
‘Fopen,pathptr/len,flags,mode’
flags is the bitwise OR of the following values:
O_CREATIf the file does not exist it will be created. The host rules apply as far as file ownership and time stamps are concerned.
O_EXCLWhen used with O_CREAT, if the file already exists it is
an error and open() fails.
O_TRUNCIf the file already exists and the open mode allows
writing (O_RDWR or O_WRONLY is given) it will be
truncated to zero length.
O_APPENDThe file is opened in append mode.
O_RDONLYThe file is opened for reading only.
O_WRONLYThe file is opened for writing only.
O_RDWRThe file is opened for reading and writing.
Other bits are silently ignored.
mode is the bitwise OR of the following values:
S_IRUSRUser has read permission.
S_IWUSRUser has write permission.
S_IRGRPGroup has read permission.
S_IWGRPGroup has write permission.
S_IROTHOthers have read permission.
S_IWOTHOthers have write permission.
Other bits are silently ignored.
open returns the new file descriptor or -1 if an error
occurred.
EEXISTpathname already exists and O_CREAT and O_EXCL were used.
EISDIRpathname refers to a directory.
EACCESThe requested access is not allowed.
ENAMETOOLONGpathname was too long.
ENOENTA directory component in pathname does not exist.
ENODEVpathname refers to a device, pipe, named pipe or socket.
EROFSpathname refers to a file on a read-only filesystem and write access was requested.
EFAULTpathname is an invalid pointer value.
ENOSPCNo space on device to create the file.
EMFILEThe process already has the maximum number of files open.
ENFILEThe limit on the total number of files open on the system has been reached.
EINTRThe call was interrupted by the user.
Next: close, Up: List of Supported Calls [Contents][Index]