Opens a file or directory and returns a file descriptor for the opened object.
#include <fcntl.h> int open ( const char *path, int oflag, ...);
(IN) Points to the path and name of the file or directory to open.
(IN) Specifies the open access mode. See File Control Open Modes.
(IN) Specifies an optional mode argument when the O_CREAT flag is specified in oflag. See File Access Modes and NetWare Attributes.
If successful, returns a file descriptor, which is a non-negative integer. If an error occurs, returns -1 and sets errno to one of the following values:
The open function returns a file descriptor that refers to a file or directory. The path parameter supplies the name of the object to open. The object is accessed according to the access mode specified by the oflag parameter.
If you opened a file, you can pass the file descriptor to other POSIX functions to perform operations on the file, such as reading and writing.
If you opened a directory, you can pass the file descriptor to the fchdir function. It does not work with any other function in LibC. This functionality was not added until July 2004. To use it, your libcthreshold needs to be greater than 405260000.
If the O_CREAT flag is set in the oflag parameter, the third parameter is a mode parameter of type mode_t. For the flags to use with this parameter, see File Access Modes and NetWare Attributes.