These functions shall fail if:
EACCES
Search permission is denied on a component of the path
prefix, or the file exists and the permissions specified
by oflag are denied, or the file does not exist and write
permission is denied for the parent directory of the file
to be created, or O_TRUNC is specified and write
permission is denied.
EEXIST
O_CREAT and O_EXCL are set, and the named file exists.
EINTR
A signal was caught during open().
EINVAL
The implementation does not support synchronized I/O for
this file.
EIO
The path argument names a STREAMS file and a hangup or
error occurred during the open().
EISDIR
The named file is a directory and oflag includes O_WRONLY
or O_RDWR, or includes O_CREAT without O_DIRECTORY.
ELOOP
A loop exists in symbolic links encountered during
resolution of the path argument, or O_NOFOLLOW was
specified and the path argument names a symbolic link.
EMFILE
All file descriptors available to the process are
currently open.
ENAMETOOLONG
The length of a component of a pathname is longer than
{NAME_MAX}.
ENFILE
The maximum allowable number of files is currently open in
the system.
ENOENT
O_CREAT is not set and a component of path does not name
an existing file, or O_CREAT is set and a component of the
path prefix of path does not name an existing file, or
path points to an empty string.
ENOENT
or ENOTDIR
O_CREAT is set, and the path argument contains at least
one non-<slash> character and ends with one or more
trailing <slash> characters. If path without the trailing
<slash> characters would name an existing file, an
[ENOENT]
error shall not occur.
ENOSR
The path argument names a STREAMS-based file and the
system is unable to allocate a STREAM.
ENOSPC
The directory or file system that would contain the new
file cannot be expanded, the file does not exist, and
O_CREAT is specified.
ENOTDIR
A component of the path prefix names an existing file that
is neither a directory nor a symbolic link to a directory;
or O_CREAT and O_EXCL are not specified, the path argument
contains at least one non-<slash> character and ends with
one or more trailing <slash> characters, and the last
pathname component names an existing file that is neither
a directory nor a symbolic link to a directory; or
O_DIRECTORY was specified and the path argument resolves
to a non-directory file.
ENXIO
O_NONBLOCK is set, the named file is a FIFO, O_WRONLY is
set, and no process has the file open for reading.
ENXIO
The named file is a character special or block special
file, and the device associated with this special file
does not exist.
EOVERFLOW
The named file is a regular file and the size of the file
cannot be represented correctly in an object of type
off_t
.
EROFS
The named file resides on a read-only file system and
either O_WRONLY, O_RDWR, O_CREAT (if the file does not
exist), or O_TRUNC is set in the oflag argument.
The openat() function shall fail if:
EACCES
The access mode of the open file description associated
with fd is not O_SEARCH and the permissions of the
directory underlying fd do not permit directory searches.
EBADF
The path argument does not specify an absolute path and
the fd argument is neither AT_FDCWD nor a valid file
descriptor open for reading or searching.
ENOTDIR
The path argument is not an absolute path and fd is a file
descriptor associated with a non-directory file.
These functions may fail if:
EAGAIN
The path argument names the slave side of a pseudo-
terminal device that is locked.
EINVAL
The value of the oflag argument is not valid.
ELOOP
More than {SYMLOOP_MAX} symbolic links were encountered
during resolution of the path argument.
ENAMETOOLONG
The length of a pathname exceeds {PATH_MAX}, or pathname
resolution of a symbolic link produced an intermediate
result with a length that exceeds {PATH_MAX}.
ENOMEM
The path argument names a STREAMS file and the system is
unable to allocate resources.
EOPNOTSUPP
The path argument names a socket.
ETXTBSY
The file is a pure procedure (shared text) file that is
being executed and oflag is O_WRONLY or O_RDWR.
The following sections are informative.