]> granicus.if.org Git - strace/blob - tests/fanotify_init.c
Update copyright headers
[strace] / tests / fanotify_init.c
1 /*
2  * Check decoding of fanotify_init syscall.
3  *
4  * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
5  * Copyright (c) 2016-2018 The strace developers.
6  * All rights reserved.
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10
11 #include "tests.h"
12
13 #include <asm/unistd.h>
14
15 #if defined __NR_fanotify_init
16
17 # include <limits.h>
18 # include <stdio.h>
19 # include <unistd.h>
20
21 /* Performs fanotify_init call via the syscall interface. */
22 static void
23 do_call(kernel_ulong_t flags, const char *flags_str,
24         kernel_ulong_t event_f_flags, const char *event_f_flags_str)
25 {
26         long rc;
27
28         rc = syscall(__NR_fanotify_init, flags, event_f_flags);
29
30         printf("fanotify_init(%s, %s) = %s\n",
31                flags_str, event_f_flags_str, sprintrc(rc));
32 }
33
34 struct strval {
35         kernel_ulong_t val;
36         const char *str;
37 };
38
39
40 int
41 main(void)
42 {
43         static const struct strval flags[] = {
44                 { F8ILL_KULONG_MASK, "FAN_CLASS_NOTIF" },
45                 { (kernel_ulong_t) 0xffffffff0000000cULL,
46                         "0xc /* FAN_CLASS_??? */" },
47                 { (kernel_ulong_t) 0xdec0deddefaced04ULL,
48                         "FAN_CLASS_CONTENT|0xefaced00 /* FAN_??? */" },
49                 { (kernel_ulong_t) 0xffffffffffffffffULL,
50                         "0xc /* FAN_CLASS_??? */|FAN_CLOEXEC|FAN_NONBLOCK|"
51                         "FAN_UNLIMITED_QUEUE|FAN_UNLIMITED_MARKS|0xffffffc0" },
52         };
53         static const struct strval event_f_flags[] = {
54                 { F8ILL_KULONG_MASK, "O_RDONLY" },
55                 { (kernel_ulong_t) 0xdeadbeef80000001ULL,
56                         "O_WRONLY|0x80000000" }
57         };
58
59         unsigned int i;
60         unsigned int j;
61
62
63         for (i = 0; i < ARRAY_SIZE(flags); i++)
64                 for (j = 0; j < ARRAY_SIZE(event_f_flags); j++)
65                         do_call(flags[i].val, flags[i].str,
66                                 event_f_flags[j].val, event_f_flags[j].str);
67
68         puts("+++ exited with 0 +++");
69         return 0;
70 }
71
72 #else
73
74 SKIP_MAIN_UNDEFINED("__NR_fanotify_init")
75
76 #endif