Debian Codegraph @

testsuite/systemtap.syscall/access.c

raw
1 /* COVERAGE: access faccessat */
2 #define _GNU_SOURCE
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8
9 // To test for glibc support for faccessat():
10 //
11 // Since glibc 2.10:
12 // _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
13 // Before glibc 2.10:
14 // _ATFILE_SOURCE
15
16 #define GLIBC_SUPPORT \
17 (_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L \
18 || defined(_ATFILE_SOURCE))
19
20 int main()
21 {
22 int fd1;
23
24 fd1 = creat("foobar1",S_IREAD|S_IWRITE);
25
26 access("foobar1", F_OK);
27 //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", F_OK) = 0
28
29 #if GLIBC_SUPPORT
30 faccessat(AT_FDCWD, "foobar1", F_OK, 0);
31 //staptest// [[[[faccessat (AT_FDCWD, "foobar1", F_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", F_OK, 0x0)]]]] = 0
32 #endif
33
34 access("foobar1", R_OK);
35 //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", R_OK) = 0
36
37 #if GLIBC_SUPPORT
38 faccessat(AT_FDCWD, "foobar1", R_OK, 0);
39 //staptest// [[[[faccessat (AT_FDCWD, "foobar1", R_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", R_OK, 0x0)]]]] = 0
40 #endif
41
42 access("foobar1", W_OK);
43 //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", W_OK) = 0
44
45 #if GLIBC_SUPPORT
46 faccessat(AT_FDCWD, "foobar1", W_OK, 0);
47 //staptest// [[[[faccessat (AT_FDCWD, "foobar1", W_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", W_OK, 0x0)]]]] = 0
48 #endif
49
50 access("foobar1", X_OK);
51 //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", X_OK) = -NNNN (EACCES)
52
53 #if GLIBC_SUPPORT
54 faccessat(AT_FDCWD, "foobar1", X_OK, 0);
55 //staptest// [[[[faccessat (AT_FDCWD, "foobar1", X_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", X_OK, 0x0)]]]] = -NNNN (EACCES)
56 #endif
57
58 access("foobar1", R_OK|W_OK);
59 //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", R_OK|W_OK) = 0
60
61 #if GLIBC_SUPPORT
62 faccessat(AT_FDCWD, "foobar1", R_OK|W_OK, 0);
63 //staptest// [[[[faccessat (AT_FDCWD, "foobar1", R_OK|W_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", R_OK|W_OK, 0x0)]]]] = 0
64 #endif
65
66 access("foobar1", R_OK|W_OK|X_OK);
67 //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", R_OK|W_OK|X_OK) = -NNNN (EACCES)
68
69 #if GLIBC_SUPPORT
70 faccessat(AT_FDCWD, "foobar1", R_OK|W_OK|X_OK, 0);
71 //staptest// [[[[faccessat (AT_FDCWD, "foobar1", R_OK|W_OK|X_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", R_OK|W_OK|X_OK, 0x0)]]]] = -NNNN (EACCES)
72 #endif
73
74 access((char *)-1, F_OK);
75 #ifdef __s390__
76 //staptest// access (0x[7]?[f]+, F_OK) = -NNNN (EFAULT)
77 #else
78 //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]0x[f]+, F_OK) = -NNNN (EFAULT)
79 #endif
80
81 access("foobar1", -1);
82 //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", R_OK|W_OK|X_OK|0x[f]+8) = -NNNN (EINVAL)
83
84 #if GLIBC_SUPPORT
85 faccessat(-1, "foobar1", F_OK, 0);
86 //staptest// [[[[faccessat (-1, "foobar1", F_OK)!!!!faccessat2 (-1, "foobar1", F_OK, 0x0)]]]] = -NNNN (EBADF)
87
88 faccessat(AT_FDCWD, (char *)-1, F_OK, 0);
89 #ifdef __s390__
90 //staptest// faccessat (AT_FDCWD, 0x[7]?[f]+, F_OK) = -NNNN (EFAULT)
91 #else
92 //staptest// [[[[faccessat (AT_FDCWD, 0x[f]+, F_OK)!!!!faccessat2 (AT_FDCWD, 0x[f]+, F_OK, 0x0)]]]] = -NNNN (EFAULT)
93 #endif
94
95 faccessat(AT_FDCWD, "foobar1", -1, 0);
96 //staptest// [[[[faccessat (AT_FDCWD, "foobar1", R_OK|W_OK|X_OK|0x[f]+8)!!!!faccessat2 (AT_FDCWD, "foobar1", R_OK|W_OK|X_OK|0x[f]+8, 0x0)]]]] = -NNNN (EINVAL)
97
98 // We can't test the last argument to faccessat() as a -1, since
99 // glibc will realize that's wrong and not issue a syscall.
100 #endif
101
102 return 0;
103 }