2 * Check decoding of inotify_init1 syscall.
4 * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
7 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include <asm/unistd.h>
14 #if defined(__NR_inotify_init1)
21 # define cloexec_flag O_CLOEXEC
23 # define cloexec_flag 0
25 # define all_flags (O_NONBLOCK | cloexec_flag)
30 static const kernel_ulong_t bogus_flags1 =
31 (kernel_ulong_t) 0xfacefeeddeadbeefULL | O_NONBLOCK;
32 static const kernel_ulong_t bogus_flags2 =
33 (kernel_ulong_t) 0x55555550ff96b77bULL & ~all_flags;
37 rc = syscall(__NR_inotify_init1, bogus_flags1);
38 printf("inotify_init1(IN_NONBLOCK|%s%#x) = %s\n",
39 bogus_flags1 & cloexec_flag ? "IN_CLOEXEC|" : "",
40 (unsigned int) (bogus_flags1 & ~all_flags),
43 rc = syscall(__NR_inotify_init1, bogus_flags2);
44 printf("inotify_init1(%#x /* IN_??? */) = %s\n",
45 (unsigned int) bogus_flags2, sprintrc(rc));
47 rc = syscall(__NR_inotify_init1, all_flags);
48 printf("inotify_init1(IN_NONBLOCK%s) = %s\n",
49 all_flags & cloexec_flag ? "|IN_CLOEXEC" : "", sprintrc(rc));
51 puts("+++ exited with 0 +++");
58 SKIP_MAIN_UNDEFINED("__NR_inotify_init1");