Commit | Line | Data |
---|---|---|
5ffa3a26 BJ |
1 | .TH CREAT 2 |
2 | .SH NAME | |
3 | creat \- create a new file | |
4 | .SH SYNOPSIS | |
5 | .B creat(name, mode) | |
6 | .br | |
7 | .B char *name; | |
8 | .SH DESCRIPTION | |
9 | .I Creat | |
10 | creates a new file or prepares to rewrite an existing | |
11 | file called | |
12 | .I name, | |
13 | given as the address of a null-terminated string. | |
14 | If the file did not exist, it is given | |
15 | mode | |
16 | .IR mode , | |
17 | as modified by the process's mode mask (see | |
18 | .IR umask (2)). | |
19 | Also see | |
20 | .IR chmod (2) | |
21 | for the | |
22 | construction of the | |
23 | .I mode | |
24 | argument. | |
25 | .PP | |
26 | If the file did exist, its mode and owner remain unchanged | |
27 | but it is truncated to 0 length. | |
28 | .PP | |
29 | The file is also opened for writing, and its file descriptor | |
30 | is returned. | |
31 | .PP | |
32 | The | |
33 | .I mode | |
34 | given is arbitrary; it need not allow | |
35 | writing. | |
36 | This feature is used by programs which deal with temporary | |
37 | files of fixed names. | |
38 | The creation is done with | |
39 | a mode that forbids writing. | |
40 | Then if a second | |
41 | instance of the program attempts a | |
42 | .I creat, | |
43 | an error is | |
44 | returned and the program knows that the name is unusable | |
45 | for the moment. | |
46 | .SH "SEE ALSO" | |
47 | write(2), close(2), chmod(2), umask (2) | |
48 | .SH DIAGNOSTICS | |
49 | The value \-1 is returned if: | |
50 | a needed directory is not searchable; | |
51 | the file does not exist and the directory | |
52 | in which it is to be created is not writable; the file | |
53 | does exist and is unwritable; | |
54 | the file is a directory; | |
55 | there are already too many files open. | |
56 | .SH "ASSEMBLER (PDP-11)" | |
57 | (creat = 8.) | |
58 | .br | |
59 | .B sys creat; name; mode | |
60 | .br | |
61 | (file descriptor in r0) | |
62 | .SH BUGS | |
63 | A file cannot be truncated while any process | |
64 | has pages set up by a | |
65 | .I vread | |
66 | on that file which have not been referenced. |