[LTP] [PATCH 3/9] syscalls/fanotify14: Add test cases for FAN_MARK_IGNORE

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


FAN_MARK_IGNORE is a new API so it also enforces strict rules about
which events and flags are allowed on a non-dir inode mark.

FAN_MARK_IGNORE requires FAN_MARK_IGNORED_SURV_MODIFY for anything
expect a non-dir inode mark.

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

diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
index 8419cea46..4a1953b33 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify14.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
@@ -39,6 +39,7 @@
 
 static int fanotify_fd;
 static int fan_report_target_fid_unsupported;
+static int ignore_mark_unsupported;
 
 /*
  * Each test case has been designed in a manner whereby the values defined
@@ -107,6 +108,34 @@ static struct test_case_t {
 		/* With FAN_REPORT_TARGET_FID, FAN_EVENT_ON_CHILD on non-dir is not valid */
 		FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME_TARGET, 0, FAN_OPEN | FAN_EVENT_ON_CHILD, ENOTDIR
 	},
+	{
+		/* FAN_MARK_IGNORE_SURV with FAN_DELETE on non-dir is not valid */
+		FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME, FAN_MARK_IGNORE_SURV, FAN_DELETE, ENOTDIR
+	},
+	{
+		/* FAN_MARK_IGNORE_SURV with FAN_RENAME on non-dir is not valid */
+		FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME, FAN_MARK_IGNORE_SURV, FAN_RENAME, ENOTDIR
+	},
+	{
+		/* FAN_MARK_IGNORE_SURV with FAN_ONDIR on non-dir is not valid */
+		FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME, FAN_MARK_IGNORE_SURV, FAN_OPEN | FAN_ONDIR, ENOTDIR
+	},
+	{
+		/* FAN_MARK_IGNORE_SURV with FAN_EVENT_ON_CHILD on non-dir is not valid */
+		FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME, FAN_MARK_IGNORE_SURV, FAN_OPEN | FAN_EVENT_ON_CHILD, ENOTDIR
+	},
+	{
+		/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on directory is not valid */
+		FAN_CLASS_NOTIF, FAN_MARK_IGNORE, FAN_OPEN, EISDIR
+	},
+	{
+		/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on mount mark is not valid */
+		FAN_CLASS_NOTIF, FAN_MARK_MOUNT | FAN_MARK_IGNORE, FAN_OPEN, EINVAL
+	},
+	{
+		/* FAN_MARK_IGNORE without FAN_MARK_IGNORED_SURV_MODIFY on filesystem mark is not valid */
+		FAN_CLASS_NOTIF, FAN_MARK_FILESYSTEM | FAN_MARK_IGNORE, FAN_OPEN, EINVAL
+	},
 };
 
 static void do_test(unsigned int number)
@@ -120,6 +149,11 @@ static void do_test(unsigned int number)
 		return;
 	}
 
+	if (ignore_mark_unsupported && tc->mark_flags & FAN_MARK_IGNORE) {
+		tst_res(TCONF, "FAN_MARK_IGNORE not supported in kernel?");
+		return;
+	}
+
 	fanotify_fd = fanotify_init(tc->init_flags, O_RDONLY);
 	if (fanotify_fd < 0) {
 		if (errno == tc->expected_errno) {
@@ -224,6 +258,7 @@ static void do_setup(void)
 
 	fan_report_target_fid_unsupported =
 		fanotify_init_flags_supported_on_fs(FAN_REPORT_DFID_NAME_TARGET, MNTPOINT);
+	ignore_mark_unsupported = fanotify_mark_supported_by_kernel(FAN_MARK_IGNORE_SURV);
 
 	/* Create temporary test file to place marks on */
 	SAFE_FILE_PRINTF(FILE1, "0");
-- 
2.25.1



More information about the ltp mailing list