2 * Check decoding of inotify_init1 syscall.
4 * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
5 * Copyright (c) 2016-2018 The strace developers.
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include <asm/unistd.h>
15 #if defined(__NR_inotify_init1)
22 # define cloexec_flag O_CLOEXEC
24 # define cloexec_flag 0
26 # define all_flags (O_NONBLOCK | cloexec_flag)
31 static const kernel_ulong_t bogus_flags1 =
32 (kernel_ulong_t) 0xfacefeeddeadbeefULL | O_NONBLOCK;
33 static const kernel_ulong_t bogus_flags2 =
34 (kernel_ulong_t) 0x55555550ff96b77bULL & ~all_flags;
38 rc = syscall(__NR_inotify_init1, bogus_flags1);
39 printf("inotify_init1(IN_NONBLOCK|%s%#x) = %s\n",
40 bogus_flags1 & cloexec_flag ? "IN_CLOEXEC|" : "",
41 (unsigned int) (bogus_flags1 & ~all_flags),
44 rc = syscall(__NR_inotify_init1, bogus_flags2);
45 printf("inotify_init1(%#x /* IN_??? */) = %s\n",
46 (unsigned int) bogus_flags2, sprintrc(rc));
48 rc = syscall(__NR_inotify_init1, all_flags);
49 printf("inotify_init1(IN_NONBLOCK%s) = %s\n",
50 all_flags & cloexec_flag ? "|IN_CLOEXEC" : "", sprintrc(rc));
52 puts("+++ exited with 0 +++");
59 SKIP_MAIN_UNDEFINED("__NR_inotify_init1");