source: trunk/minix/man/man2/creat.2@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 3.2 KB
RevLine 
[9]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.
4.\"
5.\" @(#)creat.2 6.6 (Berkeley) 5/22/86
6.\"
7.TH CREAT 2 "May 22, 1986"
8.UC 4
9.SH NAME
10creat \- create a new file
11.SH SYNOPSIS
12.nf
13.ft B
14#include <sys/types.h>
15#include <fcntl.h>
16
17int creat(const char *\fIname\fP, mode_t \fImode\fP)
18.ft R
19.fi
20.SH DESCRIPTION
21.ft B
22This interface is made obsolete by open(2), it is equivalent to
23.ft R
24.PP
25.RS
26open(\fIname\fP, O_WRONLY | O_CREAT | O_TRUNC, \fImode\fP)
27.RE
28.PP
29.B Creat
30creates a new file or prepares to rewrite an existing
31file called
32.IR name ,
33given as the address of a null-terminated string.
34If the file did not exist, it is given
35mode
36.IR mode ,
37as modified by the process's mode mask (see
38.BR umask (2)).
39Also see
40.BR chmod (2)
41for the
42construction of the
43.I mode
44argument.
45.PP
46If the file did exist, its mode and owner remain unchanged
47but it is truncated to 0 length.
48.PP
49The file is also opened for writing, and its file descriptor
50is returned.
51.SH NOTES
52The
53.I mode
54given is arbitrary; it need not allow
55writing.
56This feature has been used in the past by
57programs to construct a simple, exclusive locking
58mechanism. It is replaced by the O_EXCL open
59mode, or the advisory locking of the
60.BR fcntl (2)
61facility.
62.SH "RETURN VALUE
63The value \-1 is returned if an error occurs. Otherwise,
64the call returns a non-negative descriptor that only permits
65writing.
66.SH ERRORS
67.I Creat
68will fail and the file will not be created or truncated
69if one of the following occur:
70.TP 15
71[ENOTDIR]
72A component of the path prefix is not a directory.
73.TP 15
74[ENAMETOOLONG]
75The path name exceeds PATH_MAX characters.
76.TP 15
77[ENOENT]
78The named file does not exist.
79.TP 15
80[ELOOP]
81Too many symbolic links were encountered in translating the pathname.
82(Minix-vmd)
83.TP 15
84[EACCES]
85Search permission is denied for a component of the path prefix.
86.TP 15
87[EACCES]
88The file does not exist and the directory
89in which it is to be created is not writable.
90.TP 15
91[EACCES]
92The file exists, but it is unwritable.
93.TP 15
94[EISDIR]
95The file is a directory.
96.TP 15
97[EMFILE]
98There are already too many files open.
99.TP 15
100[ENFILE]
101The system file table is full.
102.TP 15
103[ENOSPC]
104The directory in which the entry for the new file is being placed
105cannot be extended because there is no space left on the file
106system containing the directory.
107.TP 15
108[ENOSPC]
109There are no free inodes on the file system on which the
110file is being created.
111.ig
112.TP 15
113[EDQUOT]
114The directory in which the entry for the new file
115is being placed cannot be extended because the
116user's quota of disk blocks on the file system
117containing the directory has been exhausted.
118.TP 15
119[EDQUOT]
120The user's quota of inodes on the file system on
121which the file is being created has been exhausted.
122..
123.TP 15
124[EROFS]
125The named file resides on a read-only file system.
126.TP 15
127[ENXIO]
128The file is a character special or block special file, and
129the associated device does not exist.
130.TP 15
131[EIO]
132An I/O error occurred while making the directory entry or allocating the inode.
133.TP 15
134[EFAULT]
135.I Name
136points outside the process's allocated address space.
137.SH "SEE ALSO"
138.BR open (2),
139.BR write (2),
140.BR close (2),
141.BR chmod (2),
142.BR umask (2).
Note: See TracBrowser for help on using the repository browser.