CREAT(S) XENIX System V CREAT(S)
Name
creat - Creates a new file or rewrites an existing one.
Syntax
int creat (path, mode)
char *path;
int mode;
Description
creat creates a new ordinary file or prepares to rewrite an
existing file named by the pathname pointed to by path.
If the file exists, the length is truncated to 0 and the
mode and owner are unchanged. Otherwise, the file's owner
ID is set to the process' effective user ID, the file's
group ID is set to the process' effective group ID, and the
access permission bits (i.e., the low-order 12 bits of the
file mode) are set to the value of mode. mode may have the
same values as described for chmod(S). creat will then
modify the access permission bits as follows:
All bits set in the process' file mode creation mask
are cleared. See umask(S).
The ``save text image after execution bit'' is cleared.
See chmod(S).
Upon successful completion, a non-negative integer, namely
the file descriptor, is returned and the file is open for
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(S). No process may have more than 60 files open
simultaneously. A new file may be created with a mode that
forbids writing.
creat will fail if one or more of the following are true:
A component of the path prefix is not a directory.
[ENOTDIR]
A component of the path prefix does not exist.
[ENOENT]
Search permission is denied on a component of the path
prefix. [EACCES]
The pathname is null. [ENOENT]
The file does not exist and the directory in which the
file is to be created does not permit writing.
[EACCES]
Page 1 (printed 8/7/87)
CREAT(S) XENIX System V CREAT(S)
The named file resides or would reside on a read-only
file system. [EROFS]
The file is a pure procedure (shared text) file that is
being executed. [ETXTBSY]
The file exists and write permission is denied.
[EACCES]
The named file is an existing directory. [EISDIR]
Sixty file descriptors are currently open. [EMFILE]
path points outside the process' allocated address
space. [ENOSPC]
The directory to contain the file cannot be extended.
[EFAULT]
The system file table is full. [ENFILE]
Return Value
Upon successful completion, a nonnegative integer, namely
the file descriptor, is returned. Otherwise, a value of -1
is returned and errno is set to indicate the error.
See Also
close(S), dup(S), lseek(S), open(S), read(S), umask(S),
write(S)
Notes
open(S) is preferred to creat.
Page 2 (printed 8/7/87)