]> granicus.if.org Git - strace/blob - tests/fanotify_init.c
Remove XLAT_END
[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-2019 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 "scno.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) 0xdec0deddefacec04ULL,
48                         "FAN_CLASS_CONTENT|0xefacec00 /* FAN_??? */" },
49                 { (kernel_ulong_t) 0xffffffffffffffffULL,
50                         "0xc /* FAN_CLASS_??? */|FAN_CLOEXEC|FAN_NONBLOCK|"
51                         "FAN_UNLIMITED_QUEUE|FAN_UNLIMITED_MARKS|"
52                         "FAN_ENABLE_AUDIT|FAN_REPORT_TID|FAN_REPORT_FID|"
53                         "0xfffffc80" },
54         };
55         static const struct strval event_f_flags[] = {
56                 { F8ILL_KULONG_MASK, "O_RDONLY" },
57                 { (kernel_ulong_t) 0xdeadbeef80000001ULL,
58                         "O_WRONLY|0x80000000" }
59         };
60
61         unsigned int i;
62         unsigned int j;
63
64
65         for (i = 0; i < ARRAY_SIZE(flags); i++)
66                 for (j = 0; j < ARRAY_SIZE(event_f_flags); j++)
67                         do_call(flags[i].val, flags[i].str,
68                                 event_f_flags[j].val, event_f_flags[j].str);
69
70         puts("+++ exited with 0 +++");
71         return 0;
72 }
73
74 #else
75
76 SKIP_MAIN_UNDEFINED("__NR_fanotify_init")
77
78 #endif