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
|
/*
* Check decoding of inotify_init1 syscall.
*
* Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "tests.h"
#include <asm/unistd.h>
#if defined(__NR_inotify_init1)
# include <fcntl.h>
# include <stdio.h>
# include <unistd.h>
# ifdef O_CLOEXEC
# define cloexec_flag O_CLOEXEC
# else
# define cloexec_flag 0
# endif
# define all_flags (O_NONBLOCK | cloexec_flag)
int
main(void)
{
static const kernel_ulong_t bogus_flags1 =
(kernel_ulong_t) 0xfacefeeddeadbeefULL | O_NONBLOCK;
static const kernel_ulong_t bogus_flags2 =
(kernel_ulong_t) 0x55555550ff96b77bULL & ~all_flags;
long rc;
rc = syscall(__NR_inotify_init1, bogus_flags1);
printf("inotify_init1(IN_NONBLOCK|%s%#x) = %s\n",
bogus_flags1 & cloexec_flag ? "IN_CLOEXEC|" : "",
(unsigned int) (bogus_flags1 & ~all_flags),
sprintrc(rc));
rc = syscall(__NR_inotify_init1, bogus_flags2);
printf("inotify_init1(%#x /* IN_??? */) = %s\n",
(unsigned int) bogus_flags2, sprintrc(rc));
rc = syscall(__NR_inotify_init1, all_flags);
printf("inotify_init1(IN_NONBLOCK%s) = %s\n",
all_flags & cloexec_flag ? "|IN_CLOEXEC" : "", sprintrc(rc));
puts("+++ exited with 0 +++");
return 0;
}
#else
SKIP_MAIN_UNDEFINED("__NR_inotify_init1");
#endif
|