2 * Check decoding of inotify_add_watch and inotify_rm_watch syscalls.
4 * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
5 * Copyright (c) 2016-2019 The strace developers.
8 * SPDX-License-Identifier: GPL-2.0-or-later
15 #if defined(__NR_inotify_add_watch) && defined(__NR_inotify_rm_watch)
28 ARG_STR("/abc\1/def\2/ghi\3/jkl\4/mno\5/pqr\6/stu\7/vwx\10") };
29 static const kernel_ulong_t bogus_fd =
30 (kernel_ulong_t) 0xfffffeedfffffaceULL;
31 static const kernel_ulong_t bogus_mask =
32 (kernel_ulong_t) 0xffffda7affffdeadULL;
33 static const char *bogus_mask_str = "IN_ACCESS|IN_ATTRIB|"
34 "IN_CLOSE_WRITE|IN_OPEN|IN_MOVED_TO|IN_DELETE|IN_DELETE_SELF|"
35 "IN_MOVE_SELF|IN_Q_OVERFLOW|IN_IGNORED|IN_ONLYDIR|"
36 "IN_DONT_FOLLOW|IN_EXCL_UNLINK|IN_MASK_CREATE|IN_MASK_ADD|"
37 "IN_ISDIR|IN_ONESHOT|0x8ff1000";
40 char *bogus_path = tail_memdup(bogus_path_str.path,
41 strlen(bogus_path_str.path) + 1);
43 rc = syscall(__NR_inotify_add_watch, 0, NULL, 0);
44 printf("inotify_add_watch(0, NULL, 0) = %s\n", sprintrc(rc));
46 rc = syscall(__NR_inotify_add_watch, bogus_fd, bogus_path + 4096, 0);
47 printf("inotify_add_watch(%d, %p, %u) = %s\n",
48 (int) bogus_fd, bogus_path + 4096, 0, sprintrc(rc));
50 rc = syscall(__NR_inotify_add_watch, bogus_fd, bogus_path, bogus_mask);
51 printf("inotify_add_watch(%d, %s, %s) = %s\n",
52 (int) bogus_fd, bogus_path_str.str, bogus_mask_str,
55 rc = syscall(__NR_inotify_rm_watch, 0, 0);
56 printf("inotify_rm_watch(0, 0) = %s\n", sprintrc(rc));
58 rc = syscall(__NR_inotify_rm_watch, bogus_fd, bogus_fd);
59 printf("inotify_rm_watch(%d, %d) = %s\n",
60 (int) bogus_fd, (int) bogus_fd, sprintrc(rc));
62 puts("+++ exited with 0 +++");
69 SKIP_MAIN_UNDEFINED("__NR_inotify_add_watch && __NR_inotify_rm_watch");