This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19 #include <fcntl.h>
20
21 #include "signature.h"
22 SIGNATURE_CHECK (creat, int, (const char *, mode_t));
23
24 #include <errno.h>
25 #include <stdio.h>
26 #include <unistd.h>
27
28 #include "macros.h"
29
30 #define BASE "test-creat.t"
31
32 int
33 main (void)
34 {
35 int fd;
36
37
38 unlink (BASE "file");
39 unlink (BASE "e.exe");
40
41
42 errno = 0;
43 ASSERT (creat ("nonexist.ent/", 0600) == -1);
44 ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT
45 || errno == EINVAL);
46
47
48 fd = creat (BASE "file", 0600);
49 ASSERT (0 <= fd);
50 ASSERT (close (fd) == 0);
51
52
53 fd = creat (BASE "e.exe", 0700);
54 ASSERT (0 <= fd);
55 ASSERT (close (fd) == 0);
56
57
58 ASSERT (unlink (BASE "file") == 0);
59 ASSERT (unlink (BASE "e.exe") == 0);
60
61 return 0;
62 }