[LTP] [PATCH 8/9] syscalls/fanotify10: Test FAN_MARK_IGNORE with FAN_EVENT_ON_CHILD

Amir Goldstein amir73il@gmail.com
Mon Sep 5 17:42:38 CEST 2022


Verify correct behavior with FAN_MARK_IGNORE when FAN_EVENT_ON_CHILD
flag is set in ignore mask and not in mask and when the flag is set in
mask and not in ignore mask.

We do this for 6 test cases where ignore mark is on parent dir, but not
for the one test case where both mark and ignore mask are on parent dir.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 .../kernel/syscalls/fanotify/fanotify10.c     | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
index 96c63c4ba..0095bda2a 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify10.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
@@ -418,6 +418,34 @@ add_mark:
 				mark_ignored = 0;
 				goto add_mark;
 			}
+
+			/*
+			 * When using FAN_MARK_IGNORE, verify that the FAN_EVENT_ON_CHILD
+			 * flag in mark mask does not affect the ignore mask.
+			 *
+			 * If parent does not want to ignore FAN_OPEN events on children,
+			 * set a mark mask to watch FAN_CLOSE_WRITE events on children
+			 * to make sure we do not ignore FAN_OPEN events from children.
+			 *
+			 * If parent wants to ignore FAN_OPEN events on childern,
+			 * set a mark mask to watch FAN_CLOSE events only on parent itself
+			 * to make sure we do not get FAN_CLOSE events from children.
+			 *
+			 * If we had already set the FAN_EVENT_ON_CHILD in the parent
+			 * mark mask (mark_type == FANOTIFY_PARENT), then FAN_CLOSE mask
+			 * will apply also to childern, so we skip this verification.
+			 */
+			if (mark_ignored & FAN_MARK_IGNORE &&
+			    tc->ignore_mark_type == FANOTIFY_PARENT) {
+				if (!tc->ignored_onchild)
+					mask = FAN_CLOSE_WRITE | FAN_EVENT_ON_CHILD;
+				else if (tc->mark_type == FANOTIFY_PARENT)
+					continue;
+				else
+					mask = FAN_CLOSE | FAN_ONDIR;
+				mark_ignored = 0;
+				goto add_mark;
+			}
 		}
 	}
 
-- 
2.25.1



More information about the ltp mailing list