9.5 open

int open(int dir_fd, char *path, int path_len, int flags);

open opens the passed file relative to dir_fd, depending on the flags passed. It does not create the file if not existent. By default, the file descriptor will remain open accross an exec.

flags can be an OR’d field of the following elements:

O_RDONLY (0b000001)

Makes the file able to be read.

O_WRONLY (0b000010)

Makes the file able to be written to.

O_APPEND (0b000100)

Makes the file be opened at the end of the file, instead of the beggining.

O_CLOEXEC (0b001000)

Will make the file close when exec’d.

O_NOFOLLOW (0b0100000000)

Do not follow symlinks when opening the file.

O_NONBLOCK (0b1000000000)

Make the file not block on read or write operations when possible.

The syscall returns the opened file descriptor or -1 on error, and errno is set to the following: