1CREAT(2)                      System Calls Manual                     CREAT(2)
2
3
4

NAME

6       creat - create a new file
7

SYNOPSIS

9       creat(name, mode)
10       char *name;
11

DESCRIPTION

13       This interface is made obsolete by open(2).
14
15       Creat creates a new file or prepares to rewrite an existing file called
16       name, given as the address of a null-terminated string.   If  the  file
17       did not exist, it is given mode mode, as modified by the process's mode
18       mask (see umask(2)).  Also see chmod(2) for  the  construction  of  the
19       mode argument.
20
21       If  the  file  did exist, its mode and owner remain unchanged but it is
22       truncated to 0 length.
23
24       The file is also  opened  for  writing,  and  its  file  descriptor  is
25       returned.
26

NOTES

28       The  mode  given is arbitrary; it need not allow writing.  This feature
29       has been used in the past by programs to construct a simple,  exclusive
30       locking mechanism.  It is replaced by the O_EXCL open mode, or flock(2)
31       facility.
32

RETURN VALUE

34       The value -1 is returned if  an  error  occurs.   Otherwise,  the  call
35       returns a non-negative descriptor that only permits writing.
36

ERRORS

38       Creat will fail and the file will not be created or truncated if one of
39       the following occur:
40
41       [ENOTDIR]      A component of the path prefix is not a directory.
42
43       [EINVAL]       The pathname contains a character  with  the  high-order
44                      bit set.
45
46       [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an
47                      entire path name exceeded 1023 characters.
48
49       [ENOENT]       The named file does not exist.
50
51       [ELOOP]        Too many symbolic links were encountered in  translating
52                      the pathname.
53
54       [EACCES]       Search  permission is denied for a component of the path
55                      prefix.
56
57       [EACCES]       The file does not exist and the directory in which it is
58                      to be created is not writable.
59
60       [EACCES]       The file exists, but it is unwritable.
61
62       [EISDIR]       The file is a directory.
63
64       [EMFILE]       There are already too many files open.
65
66       [ENFILE]       The system file table is full.
67
68       [ENOSPC]       The  directory  in  which  the entry for the new file is
69                      being placed cannot be  extended  because  there  is  no
70                      space left on the file system containing the directory.
71
72       [ENOSPC]       There are no free inodes on the file system on which the
73                      file is being created.
74
75       [EDQUOT]       The directory in which the entry for  the  new  file  is
76                      being placed cannot be extended because the user's quota
77                      of disk blocks on the file system containing the  direcā€
78                      tory has been exhausted.
79
80       [EDQUOT]       The  user's  quota of inodes on the file system on which
81                      the file is being created has been exhausted.
82
83       [EROFS]        The named file resides on a read-only file system.
84
85       [ENXIO]        The file is a character special or block  special  file,
86                      and the associated device does not exist.
87
88       [ETXTBSY]      The  file is a pure procedure (shared text) file that is
89                      being executed.
90
91       [EIO]          An I/O error occurred while making the  directory  entry
92                      or allocating the inode.
93
94       [EFAULT]       Name  points  outside  the  process's  allocated address
95                      space.
96
97       [EOPNOTSUPP]   The file was a socket (not currently implemented).
98

SEE ALSO

100       open(2), write(2), close(2), chmod(2), umask(2)
101
102
103
1044th Berkeley Distribution        May 22, 1986                         CREAT(2)
Impressum