The creat(2) call opens a file for writing. If the
file doesn't exist, it is created with the permissions specified by
mode; the owner and group IDs are set from the calling
process's effective user and group IDs.
If the file does exist, it's truncated to zero length. The owner
and group IDs aren't changed.
Search permission is denied for a component of the path
prefix.
[EACCES]
The required permissions (for reading and/or writing) are
denied for the given flags.
[EACCES]
The file does not exist and the directory in which it is to be
created does not permit writing.
[EEXIST]
O_CREAT and O_EXCL were specified and the file exists.
[EINTR]
The creat(2) operation was interrupted by a
signal.
[EIO]
An I/O error occurred while making the directory entry or
allocating the file serial number for O_CREAT.
[EISDIR]
The named file is a directory, and the arguments specify it is
to be opened for writing.
[ELOOP]
Too many symbolic links were encountered in translating the
pathname.
[EMFILE]
The process has already reached its limit for open file
descriptors.
[ENAMETOOLONG]
A component of a pathname exceeded {NAME_MAX} characters, or an
entire pathname exceeded {PATH_MAX} characters.
[ENFILE]
The system file table is full.
[ENOENT]
O_CREAT was not specified and the named file does not
exist.
[ENOENT]
A component of the pathname that must exist does not
exist.
[ENOSPC]
The file does not exist and the directory in which the entry
for the new file is being placed cannot be extended because there
is no space left on the file system containing the directory.
[ENOSPC]
O_CREAT is specified, the file does not exist, and there are no
free file serial numbers on the file system on which the file is
being created.
[ENOTDIR]
A component of the path prefix is not a directory.
[ENXIO]
The named file is a character special or block special file,
and the device associated with this special file does not
exist.
[EROFS]
The named file resides on a read-only file system, and the file
is to be modified.