xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/fanotify/fanotify19.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (c) 2018 Matthew Bobrowski. All Rights Reserved.
4*49cdfc7eSAndroid Build Coastguard Worker  *
5*49cdfc7eSAndroid Build Coastguard Worker  * Started by Matthew Bobrowski <[email protected]>
6*49cdfc7eSAndroid Build Coastguard Worker  */
7*49cdfc7eSAndroid Build Coastguard Worker 
8*49cdfc7eSAndroid Build Coastguard Worker /*\
9*49cdfc7eSAndroid Build Coastguard Worker  * [Description]
10*49cdfc7eSAndroid Build Coastguard Worker  * This set of tests is to ensure that the unprivileged listener feature of
11*49cdfc7eSAndroid Build Coastguard Worker  * fanotify is functioning as expected. The objective of this test file is
12*49cdfc7eSAndroid Build Coastguard Worker  * to generate a sequence of events and ensure that the returned events
13*49cdfc7eSAndroid Build Coastguard Worker  * contain the limited values that an unprivileged listener is expected
14*49cdfc7eSAndroid Build Coastguard Worker  * to receive.
15*49cdfc7eSAndroid Build Coastguard Worker  */
16*49cdfc7eSAndroid Build Coastguard Worker 
17*49cdfc7eSAndroid Build Coastguard Worker #define _GNU_SOURCE
18*49cdfc7eSAndroid Build Coastguard Worker #include "config.h"
19*49cdfc7eSAndroid Build Coastguard Worker 
20*49cdfc7eSAndroid Build Coastguard Worker #include <pwd.h>
21*49cdfc7eSAndroid Build Coastguard Worker #include <stdio.h>
22*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h>
23*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
24*49cdfc7eSAndroid Build Coastguard Worker #include <sys/wait.h>
25*49cdfc7eSAndroid Build Coastguard Worker 
26*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
27*49cdfc7eSAndroid Build Coastguard Worker 
28*49cdfc7eSAndroid Build Coastguard Worker #ifdef HAVE_SYS_FANOTIFY_H
29*49cdfc7eSAndroid Build Coastguard Worker #include "fanotify.h"
30*49cdfc7eSAndroid Build Coastguard Worker 
31*49cdfc7eSAndroid Build Coastguard Worker #define EVENT_MAX 1024
32*49cdfc7eSAndroid Build Coastguard Worker #define EVENT_SIZE (sizeof(struct fanotify_event_metadata))
33*49cdfc7eSAndroid Build Coastguard Worker #define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE)
34*49cdfc7eSAndroid Build Coastguard Worker #define EVENT_SET_MAX 48
35*49cdfc7eSAndroid Build Coastguard Worker 
36*49cdfc7eSAndroid Build Coastguard Worker #define BUF_SIZE 256
37*49cdfc7eSAndroid Build Coastguard Worker 
38*49cdfc7eSAndroid Build Coastguard Worker #define MOUNT_PATH	"fs_mnt"
39*49cdfc7eSAndroid Build Coastguard Worker #define TEST_FILE	MOUNT_PATH "/testfile"
40*49cdfc7eSAndroid Build Coastguard Worker 
41*49cdfc7eSAndroid Build Coastguard Worker static uid_t euid;
42*49cdfc7eSAndroid Build Coastguard Worker static int fd_notify;
43*49cdfc7eSAndroid Build Coastguard Worker static char buf[BUF_SIZE];
44*49cdfc7eSAndroid Build Coastguard Worker static struct fanotify_event_metadata event_buf[EVENT_BUF_LEN];
45*49cdfc7eSAndroid Build Coastguard Worker 
46*49cdfc7eSAndroid Build Coastguard Worker static struct test_case_t {
47*49cdfc7eSAndroid Build Coastguard Worker 	const char *name;
48*49cdfc7eSAndroid Build Coastguard Worker 	unsigned int fork;
49*49cdfc7eSAndroid Build Coastguard Worker 	unsigned int elevate;
50*49cdfc7eSAndroid Build Coastguard Worker 	unsigned int event_count;
51*49cdfc7eSAndroid Build Coastguard Worker 	unsigned long long event_set[EVENT_SET_MAX];
52*49cdfc7eSAndroid Build Coastguard Worker } test_cases[] = {
53*49cdfc7eSAndroid Build Coastguard Worker 	{
54*49cdfc7eSAndroid Build Coastguard Worker 		"unprivileged listener - events by self",
55*49cdfc7eSAndroid Build Coastguard Worker 		0,
56*49cdfc7eSAndroid Build Coastguard Worker 		0,
57*49cdfc7eSAndroid Build Coastguard Worker 		4,
58*49cdfc7eSAndroid Build Coastguard Worker 		{
59*49cdfc7eSAndroid Build Coastguard Worker 			FAN_OPEN,
60*49cdfc7eSAndroid Build Coastguard Worker 			FAN_ACCESS,
61*49cdfc7eSAndroid Build Coastguard Worker 			FAN_MODIFY,
62*49cdfc7eSAndroid Build Coastguard Worker 			FAN_CLOSE,
63*49cdfc7eSAndroid Build Coastguard Worker 		}
64*49cdfc7eSAndroid Build Coastguard Worker 	},
65*49cdfc7eSAndroid Build Coastguard Worker 	{
66*49cdfc7eSAndroid Build Coastguard Worker 		"unprivileged lisneter - events by child",
67*49cdfc7eSAndroid Build Coastguard Worker 		1,
68*49cdfc7eSAndroid Build Coastguard Worker 		0,
69*49cdfc7eSAndroid Build Coastguard Worker 		4,
70*49cdfc7eSAndroid Build Coastguard Worker 		{
71*49cdfc7eSAndroid Build Coastguard Worker 			FAN_OPEN,
72*49cdfc7eSAndroid Build Coastguard Worker 			FAN_ACCESS,
73*49cdfc7eSAndroid Build Coastguard Worker 			FAN_MODIFY,
74*49cdfc7eSAndroid Build Coastguard Worker 			FAN_CLOSE,
75*49cdfc7eSAndroid Build Coastguard Worker 		}
76*49cdfc7eSAndroid Build Coastguard Worker 	},
77*49cdfc7eSAndroid Build Coastguard Worker 	{
78*49cdfc7eSAndroid Build Coastguard Worker 		"unprivileged listener, privileged reader - events by self",
79*49cdfc7eSAndroid Build Coastguard Worker 		0,
80*49cdfc7eSAndroid Build Coastguard Worker 		1,
81*49cdfc7eSAndroid Build Coastguard Worker 		4,
82*49cdfc7eSAndroid Build Coastguard Worker 		{
83*49cdfc7eSAndroid Build Coastguard Worker 			FAN_OPEN,
84*49cdfc7eSAndroid Build Coastguard Worker 			FAN_ACCESS,
85*49cdfc7eSAndroid Build Coastguard Worker 			FAN_MODIFY,
86*49cdfc7eSAndroid Build Coastguard Worker 			FAN_CLOSE,
87*49cdfc7eSAndroid Build Coastguard Worker 		}
88*49cdfc7eSAndroid Build Coastguard Worker 	},
89*49cdfc7eSAndroid Build Coastguard Worker 	{
90*49cdfc7eSAndroid Build Coastguard Worker 		"unprivileged lisneter, privileged reader - events by child",
91*49cdfc7eSAndroid Build Coastguard Worker 		1,
92*49cdfc7eSAndroid Build Coastguard Worker 		1,
93*49cdfc7eSAndroid Build Coastguard Worker 		4,
94*49cdfc7eSAndroid Build Coastguard Worker 		{
95*49cdfc7eSAndroid Build Coastguard Worker 			FAN_OPEN,
96*49cdfc7eSAndroid Build Coastguard Worker 			FAN_ACCESS,
97*49cdfc7eSAndroid Build Coastguard Worker 			FAN_MODIFY,
98*49cdfc7eSAndroid Build Coastguard Worker 			FAN_CLOSE,
99*49cdfc7eSAndroid Build Coastguard Worker 		}
100*49cdfc7eSAndroid Build Coastguard Worker 	},
101*49cdfc7eSAndroid Build Coastguard Worker };
102*49cdfc7eSAndroid Build Coastguard Worker 
generate_events(void)103*49cdfc7eSAndroid Build Coastguard Worker static void generate_events(void)
104*49cdfc7eSAndroid Build Coastguard Worker {
105*49cdfc7eSAndroid Build Coastguard Worker 	int fd;
106*49cdfc7eSAndroid Build Coastguard Worker 
107*49cdfc7eSAndroid Build Coastguard Worker 	/* FAN_OPEN */
108*49cdfc7eSAndroid Build Coastguard Worker 	fd = SAFE_OPEN(TEST_FILE, O_RDWR);
109*49cdfc7eSAndroid Build Coastguard Worker 
110*49cdfc7eSAndroid Build Coastguard Worker 	/* FAN_ACCESS */
111*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_READ(0, fd, buf, BUF_SIZE);
112*49cdfc7eSAndroid Build Coastguard Worker 
113*49cdfc7eSAndroid Build Coastguard Worker 	/* FAN_MODIFY */
114*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_WRITE(SAFE_WRITE_ALL, fd, TEST_FILE, 1);
115*49cdfc7eSAndroid Build Coastguard Worker 
116*49cdfc7eSAndroid Build Coastguard Worker 	/* FAN_CLOSE */
117*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_CLOSE(fd);
118*49cdfc7eSAndroid Build Coastguard Worker }
119*49cdfc7eSAndroid Build Coastguard Worker 
do_fork(void)120*49cdfc7eSAndroid Build Coastguard Worker static void do_fork(void)
121*49cdfc7eSAndroid Build Coastguard Worker {
122*49cdfc7eSAndroid Build Coastguard Worker 	int status;
123*49cdfc7eSAndroid Build Coastguard Worker 	pid_t child;
124*49cdfc7eSAndroid Build Coastguard Worker 
125*49cdfc7eSAndroid Build Coastguard Worker 	child = SAFE_FORK();
126*49cdfc7eSAndroid Build Coastguard Worker 
127*49cdfc7eSAndroid Build Coastguard Worker 	if (child == 0) {
128*49cdfc7eSAndroid Build Coastguard Worker 		SAFE_CLOSE(fd_notify);
129*49cdfc7eSAndroid Build Coastguard Worker 		generate_events();
130*49cdfc7eSAndroid Build Coastguard Worker 		exit(0);
131*49cdfc7eSAndroid Build Coastguard Worker 	}
132*49cdfc7eSAndroid Build Coastguard Worker 
133*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_WAITPID(child, &status, 0);
134*49cdfc7eSAndroid Build Coastguard Worker 
135*49cdfc7eSAndroid Build Coastguard Worker 	if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
136*49cdfc7eSAndroid Build Coastguard Worker 		tst_brk(TBROK, "Child process terminated incorrectly. Aborting");
137*49cdfc7eSAndroid Build Coastguard Worker }
138*49cdfc7eSAndroid Build Coastguard Worker 
test_fanotify(unsigned int n)139*49cdfc7eSAndroid Build Coastguard Worker static void test_fanotify(unsigned int n)
140*49cdfc7eSAndroid Build Coastguard Worker {
141*49cdfc7eSAndroid Build Coastguard Worker 	int len = 0;
142*49cdfc7eSAndroid Build Coastguard Worker 	pid_t pid = getpid();
143*49cdfc7eSAndroid Build Coastguard Worker 	unsigned int test_number = 0;
144*49cdfc7eSAndroid Build Coastguard Worker 	struct fanotify_event_metadata *event;
145*49cdfc7eSAndroid Build Coastguard Worker 	struct test_case_t *tc = &test_cases[n];
146*49cdfc7eSAndroid Build Coastguard Worker 	struct passwd *nobody;
147*49cdfc7eSAndroid Build Coastguard Worker 
148*49cdfc7eSAndroid Build Coastguard Worker 	tst_res(TINFO, "Test #%d %s", n, tc->name);
149*49cdfc7eSAndroid Build Coastguard Worker 
150*49cdfc7eSAndroid Build Coastguard Worker 	/* Relinquish privileged user */
151*49cdfc7eSAndroid Build Coastguard Worker 	if (euid == 0) {
152*49cdfc7eSAndroid Build Coastguard Worker 		tst_res(TINFO, "Running as privileged user, revoking");
153*49cdfc7eSAndroid Build Coastguard Worker 		nobody = SAFE_GETPWNAM("nobody");
154*49cdfc7eSAndroid Build Coastguard Worker 		SAFE_SETEUID(nobody->pw_uid);
155*49cdfc7eSAndroid Build Coastguard Worker 	}
156*49cdfc7eSAndroid Build Coastguard Worker 
157*49cdfc7eSAndroid Build Coastguard Worker 	/* Initialize fanotify */
158*49cdfc7eSAndroid Build Coastguard Worker 	fd_notify = fanotify_init(FANOTIFY_REQUIRED_USER_INIT_FLAGS, O_RDONLY);
159*49cdfc7eSAndroid Build Coastguard Worker 
160*49cdfc7eSAndroid Build Coastguard Worker 	if (fd_notify < 0) {
161*49cdfc7eSAndroid Build Coastguard Worker 		if (errno == EPERM || errno == EINVAL) {
162*49cdfc7eSAndroid Build Coastguard Worker 			tst_res(TCONF,
163*49cdfc7eSAndroid Build Coastguard Worker 				"unprivileged fanotify not supported by kernel?");
164*49cdfc7eSAndroid Build Coastguard Worker 			return;
165*49cdfc7eSAndroid Build Coastguard Worker 		}
166*49cdfc7eSAndroid Build Coastguard Worker 
167*49cdfc7eSAndroid Build Coastguard Worker 		tst_brk(TBROK | TERRNO,
168*49cdfc7eSAndroid Build Coastguard Worker 			"fanotify_init(FAN_CLASS_NOTIF, O_RDONLY) failed");
169*49cdfc7eSAndroid Build Coastguard Worker 	}
170*49cdfc7eSAndroid Build Coastguard Worker 
171*49cdfc7eSAndroid Build Coastguard Worker 	/* Place mark on object */
172*49cdfc7eSAndroid Build Coastguard Worker 	if (fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_ALL_EVENTS,
173*49cdfc7eSAndroid Build Coastguard Worker 				AT_FDCWD, TEST_FILE) < 0) {
174*49cdfc7eSAndroid Build Coastguard Worker 		tst_brk(TBROK | TERRNO,
175*49cdfc7eSAndroid Build Coastguard Worker 			"fanotify_mark(%d, FAN_MARK_ADD, %d, "
176*49cdfc7eSAndroid Build Coastguard Worker 			"AT_FDCWD, %s) failed",
177*49cdfc7eSAndroid Build Coastguard Worker 			fd_notify,
178*49cdfc7eSAndroid Build Coastguard Worker 			FAN_ALL_EVENTS,
179*49cdfc7eSAndroid Build Coastguard Worker 			TEST_FILE);
180*49cdfc7eSAndroid Build Coastguard Worker 	}
181*49cdfc7eSAndroid Build Coastguard Worker 
182*49cdfc7eSAndroid Build Coastguard Worker 	/* Generate events in either child or listening process */
183*49cdfc7eSAndroid Build Coastguard Worker 	if (tc->fork)
184*49cdfc7eSAndroid Build Coastguard Worker 		do_fork();
185*49cdfc7eSAndroid Build Coastguard Worker 	else
186*49cdfc7eSAndroid Build Coastguard Worker 		generate_events();
187*49cdfc7eSAndroid Build Coastguard Worker 
188*49cdfc7eSAndroid Build Coastguard Worker 	/* Restore privileges */
189*49cdfc7eSAndroid Build Coastguard Worker 	if (euid == 0 && tc->elevate) {
190*49cdfc7eSAndroid Build Coastguard Worker 		tst_res(TINFO, "Restoring privileged user");
191*49cdfc7eSAndroid Build Coastguard Worker 		SAFE_SETEUID(0);
192*49cdfc7eSAndroid Build Coastguard Worker 	}
193*49cdfc7eSAndroid Build Coastguard Worker 
194*49cdfc7eSAndroid Build Coastguard Worker 	/* Read events from queue */
195*49cdfc7eSAndroid Build Coastguard Worker 	len = SAFE_READ(0, fd_notify, event_buf + len, EVENT_BUF_LEN - len);
196*49cdfc7eSAndroid Build Coastguard Worker 
197*49cdfc7eSAndroid Build Coastguard Worker 	event = event_buf;
198*49cdfc7eSAndroid Build Coastguard Worker 
199*49cdfc7eSAndroid Build Coastguard Worker 	/* Iterate over and validate events against expected result set */
200*49cdfc7eSAndroid Build Coastguard Worker 	while (FAN_EVENT_OK(event, len) && test_number < tc->event_count) {
201*49cdfc7eSAndroid Build Coastguard Worker 		if (!(event->mask & tc->event_set[test_number])) {
202*49cdfc7eSAndroid Build Coastguard Worker 			tst_res(TFAIL,
203*49cdfc7eSAndroid Build Coastguard Worker 				"Received unexpected event mask: mask=%llx "
204*49cdfc7eSAndroid Build Coastguard Worker 				"pid=%u fd=%d",
205*49cdfc7eSAndroid Build Coastguard Worker 				(unsigned long long) event->mask,
206*49cdfc7eSAndroid Build Coastguard Worker 				(unsigned int) event->pid,
207*49cdfc7eSAndroid Build Coastguard Worker 				event->fd);
208*49cdfc7eSAndroid Build Coastguard Worker 		} else if ((!tc->fork && event->pid != pid) ||
209*49cdfc7eSAndroid Build Coastguard Worker 			   (tc->fork && event->pid != 0)) {
210*49cdfc7eSAndroid Build Coastguard Worker 			tst_res(TFAIL,
211*49cdfc7eSAndroid Build Coastguard Worker 				"Received unexpected pid in event: "
212*49cdfc7eSAndroid Build Coastguard Worker 				"mask=%llx pid=%u (expected %u) fd=%d",
213*49cdfc7eSAndroid Build Coastguard Worker 				(unsigned long long) event->mask,
214*49cdfc7eSAndroid Build Coastguard Worker 				(unsigned int) event->pid,
215*49cdfc7eSAndroid Build Coastguard Worker 				(tc->fork ? 0 : pid),
216*49cdfc7eSAndroid Build Coastguard Worker 				event->fd);
217*49cdfc7eSAndroid Build Coastguard Worker 		} else if (event->fd != FAN_NOFD) {
218*49cdfc7eSAndroid Build Coastguard Worker 			tst_res(TFAIL,
219*49cdfc7eSAndroid Build Coastguard Worker 				"Received unexpected file descriptor: "
220*49cdfc7eSAndroid Build Coastguard Worker 				"mask=%llx pid=%u fd=%d (expected %d)",
221*49cdfc7eSAndroid Build Coastguard Worker 				(unsigned long long) event->pid,
222*49cdfc7eSAndroid Build Coastguard Worker 				(unsigned int) event->pid,
223*49cdfc7eSAndroid Build Coastguard Worker 				event->fd,
224*49cdfc7eSAndroid Build Coastguard Worker 				FAN_NOFD);
225*49cdfc7eSAndroid Build Coastguard Worker 			SAFE_CLOSE(event->fd);
226*49cdfc7eSAndroid Build Coastguard Worker 		} else {
227*49cdfc7eSAndroid Build Coastguard Worker 			tst_res(TPASS,
228*49cdfc7eSAndroid Build Coastguard Worker 				"Received event: mask=%llx, pid=%u fd=%d",
229*49cdfc7eSAndroid Build Coastguard Worker 				(unsigned long long) event->mask,
230*49cdfc7eSAndroid Build Coastguard Worker 				(unsigned int) event->pid,
231*49cdfc7eSAndroid Build Coastguard Worker 				event->fd);
232*49cdfc7eSAndroid Build Coastguard Worker 		}
233*49cdfc7eSAndroid Build Coastguard Worker 
234*49cdfc7eSAndroid Build Coastguard Worker 		/* Non-permission events can be merged into a single event. */
235*49cdfc7eSAndroid Build Coastguard Worker 		event->mask &= ~tc->event_set[test_number];
236*49cdfc7eSAndroid Build Coastguard Worker 
237*49cdfc7eSAndroid Build Coastguard Worker 		if (event->mask == 0)
238*49cdfc7eSAndroid Build Coastguard Worker 			event = FAN_EVENT_NEXT(event, len);
239*49cdfc7eSAndroid Build Coastguard Worker 		test_number++;
240*49cdfc7eSAndroid Build Coastguard Worker 	}
241*49cdfc7eSAndroid Build Coastguard Worker 
242*49cdfc7eSAndroid Build Coastguard Worker 	/*
243*49cdfc7eSAndroid Build Coastguard Worker 	 * Determine whether there is still unprocessed events remaining in the
244*49cdfc7eSAndroid Build Coastguard Worker 	 * buffer. This is to cover the basis whereby the event processing loop
245*49cdfc7eSAndroid Build Coastguard Worker 	 * terminates prematurely. In that case, we need to ensure that any
246*49cdfc7eSAndroid Build Coastguard Worker 	 * event file descriptor that is open is closed so that the temporary
247*49cdfc7eSAndroid Build Coastguard Worker 	 * filesystem can be unmounted.
248*49cdfc7eSAndroid Build Coastguard Worker 	 */
249*49cdfc7eSAndroid Build Coastguard Worker 	if (FAN_EVENT_OK(event, len)) {
250*49cdfc7eSAndroid Build Coastguard Worker 		tst_res(TFAIL,
251*49cdfc7eSAndroid Build Coastguard Worker 			"Event processing loop exited prematurely. Did NOT "
252*49cdfc7eSAndroid Build Coastguard Worker 			"finish processing events in buffer. Cleaning up.");
253*49cdfc7eSAndroid Build Coastguard Worker 		while (FAN_EVENT_OK(event, len)) {
254*49cdfc7eSAndroid Build Coastguard Worker 			if (event->fd != FAN_NOFD)
255*49cdfc7eSAndroid Build Coastguard Worker 				SAFE_CLOSE(event->fd);
256*49cdfc7eSAndroid Build Coastguard Worker 			event = FAN_EVENT_NEXT(event, len);
257*49cdfc7eSAndroid Build Coastguard Worker 		}
258*49cdfc7eSAndroid Build Coastguard Worker 	}
259*49cdfc7eSAndroid Build Coastguard Worker 
260*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_CLOSE(fd_notify);
261*49cdfc7eSAndroid Build Coastguard Worker }
262*49cdfc7eSAndroid Build Coastguard Worker 
setup(void)263*49cdfc7eSAndroid Build Coastguard Worker static void setup(void)
264*49cdfc7eSAndroid Build Coastguard Worker {
265*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_FILE_PRINTF(TEST_FILE, "1");
266*49cdfc7eSAndroid Build Coastguard Worker 	SAFE_CHMOD(TEST_FILE, 0666);
267*49cdfc7eSAndroid Build Coastguard Worker 
268*49cdfc7eSAndroid Build Coastguard Worker 	/* Check for kernel fanotify support */
269*49cdfc7eSAndroid Build Coastguard Worker 	REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(FAN_REPORT_FID, TEST_FILE);
270*49cdfc7eSAndroid Build Coastguard Worker 
271*49cdfc7eSAndroid Build Coastguard Worker 	euid = geteuid();
272*49cdfc7eSAndroid Build Coastguard Worker }
273*49cdfc7eSAndroid Build Coastguard Worker 
cleanup(void)274*49cdfc7eSAndroid Build Coastguard Worker static void cleanup(void)
275*49cdfc7eSAndroid Build Coastguard Worker {
276*49cdfc7eSAndroid Build Coastguard Worker 	if (fd_notify > 0)
277*49cdfc7eSAndroid Build Coastguard Worker 		SAFE_CLOSE(fd_notify);
278*49cdfc7eSAndroid Build Coastguard Worker }
279*49cdfc7eSAndroid Build Coastguard Worker 
280*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
281*49cdfc7eSAndroid Build Coastguard Worker 	.test = test_fanotify,
282*49cdfc7eSAndroid Build Coastguard Worker 	.tcnt = ARRAY_SIZE(test_cases),
283*49cdfc7eSAndroid Build Coastguard Worker 	.setup = setup,
284*49cdfc7eSAndroid Build Coastguard Worker 	.cleanup = cleanup,
285*49cdfc7eSAndroid Build Coastguard Worker 	.forks_child = 1,
286*49cdfc7eSAndroid Build Coastguard Worker 	.needs_root = 1,
287*49cdfc7eSAndroid Build Coastguard Worker 	.mount_device = 1,
288*49cdfc7eSAndroid Build Coastguard Worker 	.mntpoint = MOUNT_PATH,
289*49cdfc7eSAndroid Build Coastguard Worker 	.tags = (const struct tst_tag[]) {
290*49cdfc7eSAndroid Build Coastguard Worker 		{"linux-git", "a8b98c808eab"},
291*49cdfc7eSAndroid Build Coastguard Worker 		{}
292*49cdfc7eSAndroid Build Coastguard Worker 	}
293*49cdfc7eSAndroid Build Coastguard Worker };
294*49cdfc7eSAndroid Build Coastguard Worker 
295*49cdfc7eSAndroid Build Coastguard Worker #else
296*49cdfc7eSAndroid Build Coastguard Worker 	TST_TEST_TCONF("system doesn't have required fanotify support");
297*49cdfc7eSAndroid Build Coastguard Worker #endif
298