1CREAT(2) System Calls Manual CREAT(2)
2
3
4
6 creat - create a new file
7
9 creat(name, mode)
10 char *name;
11
13 Creat creates a new file or prepares to rewrite an existing file called
14 name, given as the address of a null-terminated string. If the file
15 did not exist, it is given mode mode, as modified by the process's mode
16 mask (see umask(2)). Also see chmod(2) for the construction of the
17 mode argument.
18
19 If the file did exist, its mode and owner remain unchanged but it is
20 truncated to 0 length.
21
22 The file is also opened for writing, and its file descriptor is
23 returned.
24
25 The mode given is arbitrary; it need not allow writing. This feature
26 is used by programs which deal with temporary files of fixed names.
27 The creation is done with a mode that forbids writing. Then if a sec‐
28 ond instance of the program attempts a creat, an error is returned and
29 the program knows that the name is unusable for the moment.
30
32 write(2), close(2), chmod(2), umask (2)
33
35 The value -1 is returned if: a needed directory is not searchable; the
36 file does not exist and the directory in which it is to be created is
37 not writable; the file does exist and is unwritable; the file is a
38 directory; there are already too many files open.
39
41 (creat = 8.)
42 sys creat; name; mode
43 (file descriptor in r0)
44
45
46
47 CREAT(2)