Debian Codegraph @

testsuite/systemtap.syscall/inotify.c

raw
1 /* COVERAGE: inotify_init inotify_init1 inotify_add_watch inotify_rm_watch */
2
3 #define _GNU_SOURCE
4 #include <unistd.h>
5 #include <sys/syscall.h>
6 #include <sys/inotify.h>
7 #include <sys/mman.h>
8
9 int main()
10 {
11 mlockall(MCL_CURRENT);
12
13 int fd = inotify_init();
14 //staptest// [[[[inotify_init (!!!!inotify_init1 (0x0]]]]) = NNNN
15
16 int wd = inotify_add_watch(fd, "/tmp", IN_ALL_EVENTS);
17 //staptest// inotify_add_watch (NNNN, "/tmp", IN_ACCESS|IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_CLOSE_NOWRITE|IN_OPEN|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF) = NNNN
18
19 inotify_rm_watch(fd, wd);
20 //staptest// inotify_rm_watch (NNNN, NNNN) = 0
21
22 #ifdef IN_CLOEXEC
23 inotify_init1(IN_NONBLOCK);
24 //staptest// inotify_init1 (IN_NONBLOCK) = NNNN
25
26 inotify_init1(IN_CLOEXEC);
27 //staptest// inotify_init1 (IN_CLOEXEC) = NNNN
28
29 inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
30 //staptest// inotify_init1 (IN_NONBLOCK|IN_CLOEXEC) = NNNN
31 #endif
32
33 #ifdef __NR_inotify_init1
34 inotify_init1(-1);
35 //staptest// inotify_init1 (IN_[^ ]+|XXXX) = -NNNN
36 #endif
37
38 inotify_add_watch(-1, "/tmp", IN_MODIFY);
39 //staptest// inotify_add_watch (-1, "/tmp", IN_MODIFY) = -NNNN
40
41 inotify_add_watch(fd, (char *)-1, IN_MODIFY);
42 #ifdef __s390__
43 //staptest// inotify_add_watch (NNNN, 0x[7]?[f]+, IN_MODIFY) = -NNNN (EFAULT)
44 #else
45 //staptest// inotify_add_watch (NNNN, 0x[f]+, IN_MODIFY) = -NNNN (EFAULT)
46 #endif
47
48 // We've got a problem here. On a 32-bit kernel (i686 for instance),
49 // MAXSTRINGLEN is only 256. Passing a -1 as the mount flags value
50 // can produce a string that will cause argstr to get too big. So,
51 // we'll make the end of the arguments optional.
52 wd = inotify_add_watch(fd, "/tmp", -1);
53 //staptest// inotify_add_watch (NNNN, "/tmp", IN_[^ ]+[[[[|XXXX]]]]?) = NNNN
54
55 inotify_rm_watch(fd, wd);
56 //staptest// inotify_rm_watch (NNNN, NNNN) = NNNN
57
58 inotify_rm_watch(-1, wd);
59 //staptest// inotify_rm_watch (-1, NNNN) = -NNNN (EBADF)
60
61 inotify_rm_watch(fd, -1);
62 //staptest// inotify_rm_watch (NNNN, -1) = -NNNN (EINVAL)
63
64 return 0;
65 }