1 .\" Copyright (c) 1980 Regents of the University of California.
2 .\" All rights reserved. The Berkeley software License Agreement
3 .\" specifies the terms and conditions for redistribution.
5 .\" @(#)creat.2 6.6 (Berkeley) 5/22/86
7 .TH CREAT 2 "May 22, 1986"
10 creat \- create a new file
14 #include <sys/types.h>
17 int creat(const char *\fIname\fP, mode_t \fImode\fP)
22 This interface is made obsolete by open(2), it is equivalent to
26 open(\fIname\fP, O_WRONLY | O_CREAT | O_TRUNC, \fImode\fP)
30 creates a new file or prepares to rewrite an existing
33 given as the address of a null-terminated string.
34 If the file did not exist, it is given
37 as modified by the process's mode mask (see
46 If the file did exist, its mode and owner remain unchanged
47 but it is truncated to 0 length.
49 The file is also opened for writing, and its file descriptor
54 given is arbitrary; it need not allow
56 This feature has been used in the past by
57 programs to construct a simple, exclusive locking
58 mechanism. It is replaced by the O_EXCL open
59 mode, or the advisory locking of the
63 The value \-1 is returned if an error occurs. Otherwise,
64 the call returns a non-negative descriptor that only permits
68 will fail and the file will not be created or truncated
69 if one of the following occur:
72 A component of the path prefix is not a directory.
75 The path name exceeds PATH_MAX characters.
78 The named file does not exist.
81 Too many symbolic links were encountered in translating the pathname.
85 Search permission is denied for a component of the path prefix.
88 The file does not exist and the directory
89 in which it is to be created is not writable.
92 The file exists, but it is unwritable.
95 The file is a directory.
98 There are already too many files open.
101 The system file table is full.
104 The directory in which the entry for the new file is being placed
105 cannot be extended because there is no space left on the file
106 system containing the directory.
109 There are no free inodes on the file system on which the
110 file is being created.
114 The directory in which the entry for the new file
115 is being placed cannot be extended because the
116 user's quota of disk blocks on the file system
117 containing the directory has been exhausted.
120 The user's quota of inodes on the file system on
121 which the file is being created has been exhausted.
125 The named file resides on a read-only file system.
128 The file is a character special or block special file, and
129 the associated device does not exist.
132 An I/O error occurred while making the directory entry or allocating the inode.
136 points outside the process's allocated address space.