Open

The open syscall allows one to open a file, fifo or device (sockets are handled with the socket syscall). Open takes 3 arguments, the first is the pathname of what is to be opened, the second is flags that determine whether this file is newly created, opened for writing or reading (or both), truncated, appended, etc. The third argument is the mode that a file is going to be created (when reading a file this is irrelevant). The mode depends on the umask that is set in the program. Open returns with -1 on error and sets errno if it failed.