File: access.c

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (103 lines) | stat: -rw-r--r-- 3,469 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* COVERAGE: access faccessat */
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

// To test for glibc support for faccessat():
//
// Since glibc 2.10:
//	_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
// Before glibc 2.10:
//	_ATFILE_SOURCE

#define GLIBC_SUPPORT \
  (_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L \
   || defined(_ATFILE_SOURCE))

int main()
{
  int fd1;

  fd1 = creat("foobar1",S_IREAD|S_IWRITE);

  access("foobar1", F_OK);
  //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", F_OK) = 0

#if GLIBC_SUPPORT
  faccessat(AT_FDCWD, "foobar1", F_OK, 0);
  //staptest// [[[[faccessat (AT_FDCWD, "foobar1", F_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", F_OK, 0x0)]]]] = 0
#endif

  access("foobar1", R_OK);
  //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", R_OK) = 0

#if GLIBC_SUPPORT
  faccessat(AT_FDCWD, "foobar1", R_OK, 0);
  //staptest// [[[[faccessat (AT_FDCWD, "foobar1", R_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", R_OK, 0x0)]]]] = 0
#endif

  access("foobar1", W_OK);
  //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", W_OK) = 0

#if GLIBC_SUPPORT
  faccessat(AT_FDCWD, "foobar1", W_OK, 0);
  //staptest// [[[[faccessat (AT_FDCWD, "foobar1", W_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", W_OK, 0x0)]]]] = 0
#endif

  access("foobar1", X_OK);
  //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", X_OK) = -NNNN (EACCES)

#if GLIBC_SUPPORT
  faccessat(AT_FDCWD, "foobar1", X_OK, 0);
  //staptest// [[[[faccessat (AT_FDCWD, "foobar1", X_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", X_OK, 0x0)]]]] = -NNNN (EACCES)
#endif

  access("foobar1", R_OK|W_OK);
  //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", R_OK|W_OK) = 0

#if GLIBC_SUPPORT
  faccessat(AT_FDCWD, "foobar1", R_OK|W_OK, 0);
  //staptest// [[[[faccessat (AT_FDCWD, "foobar1", R_OK|W_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", R_OK|W_OK, 0x0)]]]] = 0
#endif

  access("foobar1", R_OK|W_OK|X_OK);
  //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", R_OK|W_OK|X_OK) = -NNNN (EACCES)

#if GLIBC_SUPPORT
  faccessat(AT_FDCWD, "foobar1", R_OK|W_OK|X_OK, 0);
  //staptest// [[[[faccessat (AT_FDCWD, "foobar1", R_OK|W_OK|X_OK)!!!!faccessat2 (AT_FDCWD, "foobar1", R_OK|W_OK|X_OK, 0x0)]]]] = -NNNN (EACCES)
#endif

  access((char *)-1, F_OK);
#ifdef __s390__
  //staptest// access (0x[7]?[f]+, F_OK) = -NNNN (EFAULT)
#else
  //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]0x[f]+, F_OK) = -NNNN (EFAULT)
#endif

  access("foobar1", -1);
  //staptest// [[[[access (!!!!faccessat (AT_FDCWD, ]]]]"foobar1", R_OK|W_OK|X_OK|0x[f]+8) = -NNNN (EINVAL)

#if GLIBC_SUPPORT
  faccessat(-1, "foobar1", F_OK, 0);
  //staptest// [[[[faccessat (-1, "foobar1", F_OK)!!!!faccessat2 (-1, "foobar1", F_OK, 0x0)]]]] = -NNNN (EBADF)

  faccessat(AT_FDCWD, (char *)-1, F_OK, 0);
#ifdef __s390__
  //staptest// faccessat (AT_FDCWD, 0x[7]?[f]+, F_OK) = -NNNN (EFAULT)
#else
  //staptest// [[[[faccessat (AT_FDCWD, 0x[f]+, F_OK)!!!!faccessat2 (AT_FDCWD, 0x[f]+, F_OK, 0x0)]]]] = -NNNN (EFAULT)
#endif

  faccessat(AT_FDCWD, "foobar1", -1, 0);
  //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)

  // We can't test the last argument to faccessat() as a -1, since
  // glibc will realize that's wrong and not issue a syscall.
#endif

  return 0;
}