.\" Copyright (c) 1980 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)creat.2 5.1 (Berkeley) %G%
.TH CREAT 2 "2 July 1983"
creat \- create a new file
.B "This interface is obsoleted by open(2).
creates a new file or prepares to rewrite an existing
given as the address of a null-terminated string.
If the file did not exist, it is given
as modified by the process's mode mask (see
If the file did exist, its mode and owner remain unchanged
but it is truncated to 0 length.
The file is also opened for writing, and its file descriptor
given is arbitrary; it need not allow
This feature has been used in the past by
programs to construct a simple exclusive locking
mechanism. It is replaced by the O_EXCL open
The value \-1 is returned if an error occurs. Otherwise,
the call returns a non-negative descriptor which only permits
will fail and the file will not be created or truncated
if one of the following occur:
The argument contains a byte with the high-order bit set.
A component of the path prefix is not a directory.
A needed directory does not have search permission.
The file does not exist and the directory
in which it is to be created is not writable.
The file exists, but it is unwritable.
There are already too many files open.
The named file resides on a read-only file system.
The file is a character special or block special file, and
the associated device does not exist.
The file is a pure procedure (shared text) file that is being
points outside the process's allocated address space.
Too many symbolic links were encountered in translating the
The file was a socket (not currently implemented).
open(2), write(2), close(2), chmod(2), umask(2)