open (Debugging with GDB)
Next: close, Up: List of Supported Calls [Contents][Index]
open
- Synopsis:
int open(const char *pathname, int flags); int open(const char *pathname, int flags, mode_t mode);
- Request:
‘
Fopen,pathptr/len,flags,mode’flagsis the bitwiseORof 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_RDWRorO_WRONLYis 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.
modeis the bitwiseORof 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.
- Return value:
openreturns the new file descriptor or -1 if an error occurred.- Errors:
EEXISTpathnamealready exists andO_CREATandO_EXCLwere used.EISDIRpathnamerefers to a directory.EACCESThe requested access is not allowed.
ENAMETOOLONGpathnamewas too long.ENOENTA directory component in
pathnamedoes not exist.ENODEVpathnamerefers to a device, pipe, named pipe or socket.EROFSpathnamerefers to a file on a read-only filesystem and write access was requested.EFAULTpathnameis 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]