466
|
1 <refentry id="creat">
|
|
2 <refnamediv>
|
468
|
3 <refname>Creat</refname>
|
|
4 <refpurpose>create a file</refpurpose>
|
466
|
5 </refnamediv>
|
|
6
|
|
7 <refsynopsisdiv>
|
|
8 <funcsynopsis>
|
468
|
9 <funcsynopsisinfo>
|
|
10 #include <modes.h>
|
|
11 </funcsynopsisinfo>
|
466
|
12 <funcprototype>
|
|
13 <funcdef><function>creat</function></funcdef>
|
570
|
14 <paramdef>char *<parameter>fname</parameter></paramdef>
|
|
15 <paramdef>int <parameter>perm</parameter></paramdef>
|
466
|
16 </funcprototype>
|
|
17 </funcsynopsis>
|
|
18
|
|
19 </refsynopsisdiv>
|
|
20
|
540
|
21 <refsect1><title>Assembler Equivalent</title>
|
|
22 <para>
|
|
23 os9 I$CREATE
|
|
24 </para>
|
|
25 </refsect1>
|
|
26
|
466
|
27 <refsect1><title>Description</title>
|
|
28 <para>
|
594
|
29 Creat returns a path number to a new file available for
|
|
30 writing, giving it the permissions specified in "perm" and
|
|
31 making the task user the owner. If, however, "fname" is the
|
|
32 name of an existing file, the file is truncated to zero length,
|
|
33 and the ownership and permissions remain unchanged. NOTE,
|
|
34 that unlike the OS-9 assembler service request, creat does
|
|
35 not return an error if the file already exists. "Access()"
|
|
36 should be used to establish the existence of a file if it is
|
|
37 important that a file should not be overwritten.
|
|
38 </para>
|
|
39 <para>
|
|
40 It is unnecessary to specify writing permissions in "perm" in
|
|
41 order to write to the file in the current task.
|
|
42 </para>
|
|
43 <para>
|
|
44 The permissions allowed are defined in the include file as
|
|
45 follows:
|
|
46 </para>
|
|
47 <programlisting>
|
|
48 #define S_IPRM 0xff /* mask for permission bits */
|
|
49 #define S_IREAD 0x01 /* owner read */
|
|
50 #define S_IWRITE 0x02 /* owner write */
|
|
51 #define S_IEXEC 0x04 /* owner execute */
|
|
52 #define S_IOREAD 0x08 /* public read */
|
|
53 #define S_IOWRITE 0x10 /* public write */
|
|
54 #define S_IOEXEC 0x20 /* public execute */
|
|
55 #define S_ISHARE 0x40 /* sharable */
|
|
56 </programlisting>
|
|
57 <para>
|
|
58 Directories may not be created with this call; use "mknod()"
|
|
59 instead.
|
466
|
60 </para>
|
|
61 </refsect1>
|
540
|
62
|
552
|
63 <refsect1><title>Diagnostics</title>
|
|
64 <para>
|
|
65 This call returns -1 if there are too many files open. If the
|
|
66 pathname cannot be searched, if permission to write is denied,
|
|
67 or if the file exists and is a directory.
|
|
68 </para>
|
|
69 </refsect1>
|
|
70
|
540
|
71 <refsect1><title>See Also</title>
|
|
72 <para>
|
|
73 <link linkend="write">write()</link>,
|
|
74 <link linkend="close">close()</link>,
|
|
75 <link linkend="chmod">chmod()</link>
|
|
76 </para>
|
|
77 </refsect1>
|
466
|
78 </refentry>
|