CREAT(2)
NAME
creat − create a new file (obsolete)
USAGE
creat(name, mode) char *name;
DESCRIPTION
This interface has been made obsolete by open(2).
Creat creates a new file or prepares to rewrite an existing file called name, given as the address of a null-terminated string. If the file did not exist, it is created with mode, as modified by the process’s mode mask (see umask(2)). Also see chmod(2) for the construction of the mode argument.
If the file did exist, its mode and owner remain unchanged, but it is truncated to zero length. The file is also opened for writing, and its file descriptor is returned.
NOTES
The mode given is arbitrary; it need not allow writing. In the past, a mode that did not allow writing let programs construct a simple exclusive locking mechanism. This function has been replaced by the O_EXCL mode of open(2), and by the flock(2) facility.
The DOMAIN System’s single level store architecture requires that all filesystem objects be readable by their owner. Since DOMAIN/IX does not allow write-only or execute-only files, modes 00100 (write only by owner) and 00200 (execute only by owner) are effectively ORed with 00400 to force read permission for the owner.
RETURN VALUE
A successful call returns a non-negative integer file descriptor that only permits writing. A failed call returns -1 and sets errno as indicated below.
ERRORS
Creat will fail and the file will not be created or truncated if one of the following occur:
[EPERM] The argument contains a byte with the high-order bit set.
[ENOTDIR] A component of the path prefix is not a directory.
[EACCES] A needed directory does not have search permission.
[EACCES] The file does not exist and the directory in which it would be created is not writable.
[EACCES] The file exists, but it is unwritable.
[EISDIR] The file is a directory.
[EMFILE] There are already too many files open.
[EROFS] The named file resides on a read-only file system.
[ENXIO] The file is a character-special or block-special file, and the associated device does not exist.
[ETXTBSY] The file is a pure procedure (shared text) file that is being executed.
[EFAULT] Name points outside the process’s allocated address space.
[ELOOP] The call encountered too many symbolic links in translating the pathname.
[EOPNOTSUPP] The file was a socket (not currently implemented).