1creat(2)                         System Calls                         creat(2)
2
3
4

NAME

6       creat - create a new file or rewrite an existing one
7

SYNOPSIS

9       #include <sys/stat.h>
10       #include <fcntl.h>
11
12       int creat(const char *path, mode_t mode);
13
14

DESCRIPTION

16       The function call
17
18
19       creat(path, mode)
20
21
22       is equivalent to:
23
24
25       open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)
26

RETURN VALUES

28       Refer to open(2).
29

ERRORS

31       Refer to open(2).
32

EXAMPLES

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

USAGE

53       The  creat() function has a transitional interface for 64-bit file off‐
54       sets.  See lf64(5).
55

ATTRIBUTES

57       See attributes(5) for descriptions of the following attributes:
58
59
60
61
62       ┌─────────────────────────────┬─────────────────────────────┐
63       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
64       ├─────────────────────────────┼─────────────────────────────┤
65       │Interface Stability          │Standard                     │
66       ├─────────────────────────────┼─────────────────────────────┤
67       │MT-Level                     │Async-Signal-Safe            │
68       └─────────────────────────────┴─────────────────────────────┘
69

SEE ALSO

71       open(2), attributes(5), largefile(5), lf64(5), standards(5)
72
73
74
75SunOS 5.11                        25 Mar 2002                         creat(2)
Impressum