1CREAT(3P)                  POSIX Programmer's Manual                 CREAT(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       creat - create a new file or rewrite an existing one
13

SYNOPSIS

15       #include <sys/stat.h>
16       #include <fcntl.h>
17
18       int creat(const char *path, mode_t mode);
19
20

DESCRIPTION

22       The function call:
23
24
25              creat(path, mode)
26
27       shall be equivalent to:
28
29
30              open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)
31

RETURN VALUE

33       Refer to open().
34

ERRORS

36       Refer to open().
37
38       The following sections are informative.
39

EXAMPLES

41   Creating a File
42       The following example creates the file /tmp/file with  read  and  write
43       permissions  for  the file owner and read permission for group and oth‐
44       ers. The resulting file descriptor is assigned to the fd variable.
45
46
47              #include <fcntl.h>
48              ...
49              int fd;
50              mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
51              char *filename = "/tmp/file";
52              ...
53              fd = creat(filename, mode);
54              ...
55

APPLICATION USAGE

57       None.
58

RATIONALE

60       The creat() function is redundant. Its services are  also  provided  by
61       the open() function. It has been included primarily for historical pur‐
62       poses since many existing applications depend on it. It is best consid‐
63       ered a part of the C binding rather than a function that should be pro‐
64       vided in other languages.
65

FUTURE DIRECTIONS

67       None.
68

SEE ALSO

70       open(), the Base Definitions volume of IEEE Std 1003.1-2001, <fcntl.h>,
71       <sys/stat.h>, <sys/types.h>
72
74       Portions  of  this text are reprinted and reproduced in electronic form
75       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
76       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
77       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
78       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
79       event of any discrepancy between this version and the original IEEE and
80       The  Open Group Standard, the original IEEE and The Open Group Standard
81       is the referee document. The original Standard can be  obtained  online
82       at http://www.opengroup.org/unix/online.html .
83
84
85
86IEEE/The Open Group                  2003                            CREAT(3P)
Impressum