CREAT(2) DOMAIN/IX SYS5 CREAT(2)
NAME
creat - create a new file or write over an existing one
USAGE
int creat(path, mode)
char *path;
int mode;
DESCRIPTION
Creat creates a new file or writes over an existing file.
The file is specified by path.
If path exists when creat is called, the file's contents are
discarded and the length of the file is set to zero. The
file's owner and mode are not changed.
If Apath does not exist, creat sets the file's owner ID to
the effective user ID of the process, and the group ID of
the process to the effective group ID of the process. The
call also sets the low-order 12 bits of the file mode to the
value of mode. All bits set in the process's file mode
creation mask are cleared. See umask(2).
Upon successful completion, creat returns the file descrip-
tor and opens the file writing even if the mode does not
permit writing. The file pointer is set to the beginning of
the file. The file descriptor is set to remain open across
exec system calls. See fcntl(2). A new file may be created
with a mode that forbids writing.
RETURN VALUE
A successful call returns a non-negative integer file
descriptor. A failed call returns -1 and sets errno as
indicated below.
ERRORS
Creat fails if one or more of the following is true:
[ENOTDIR] A component of the path prefix is not a directory.
[ENOENT] A component of the path prefix does not exist.
[EACCES] Search permission is denied on a component of the
path prefix.
[ENOENT] The pathname is null.
[EACCES] The file does not exist and the directory in which
the file is to be created does not permit writing.
Printed 12/4/86 CREAT-1
CREAT(2) DOMAIN/IX SYS5 CREAT(2)
[EROFS] The named file resides (or would reside) on a
read-only file system.
[ETXTBSY] The file is a pure procedure (shared text) file
that is being executed.
[EACCES] The file exists and write permission is denied.
[EISDIR] The named file is an existing directory.
[EMFILE] The maximum number of open file descriptors would
be exceeded.
[EFAULT] Path points outside the allocated address space of
the process.
[ENFILE] The system file table is full.
RELATED INFORMATION
chmod(2), close(2), dup(2), fcntl(2), lseek(2), open(2),
read(2), umask(2), write(2)
CREAT-2 Printed 12/4/86