[LTP] [PATCH 2/6] syscalls/fanotify14: Add tests for FAN_REPORT_TARGET_FID and FAN_RENAME

Amir Goldstein amir73il@gmail.com
Thu Apr 14 16:53:53 CEST 2022


Validate flag combinations:
1) FAN_REPORT_TARGET_FID requires FAN_REPORT_NAME and FAN_REPORT_FID
2) FAN_RENAME requires FAN_REPORT_NAME

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 testcases/kernel/syscalls/fanotify/fanotify.h   | 15 +++++++++++++++
 testcases/kernel/syscalls/fanotify/fanotify14.c | 12 ++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index b2855d292..eb690e332 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -81,6 +81,11 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,
 #ifndef FAN_REPORT_PIDFD
 #define FAN_REPORT_PIDFD	0x00000080
 #endif
+#ifndef FAN_REPORT_TARGET_FID
+#define FAN_REPORT_TARGET_FID	0x00001000
+#define FAN_REPORT_DFID_NAME_TARGET (FAN_REPORT_DFID_NAME | \
+                                     FAN_REPORT_FID | FAN_REPORT_TARGET_FID)
+#endif
 
 /* Non-uapi convenience macros */
 #ifndef FAN_REPORT_DFID_NAME_FID
@@ -130,6 +135,9 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,
 #ifndef FAN_FS_ERROR
 #define FAN_FS_ERROR		0x00008000
 #endif
+#ifndef FAN_RENAME
+#define FAN_RENAME		0x10000000
+#endif
 
 /* Additional error status codes that can be returned to userspace */
 #ifndef FAN_NOPIDFD
@@ -185,6 +193,13 @@ typedef struct {
 #define FAN_EVENT_INFO_TYPE_ERROR	5
 #endif
 
+#ifndef FAN_EVENT_INFO_TYPE_OLD_DFID_NAME
+#define FAN_EVENT_INFO_TYPE_OLD_DFID_NAME	10
+#endif
+#ifndef FAN_EVENT_INFO_TYPE_NEW_DFID_NAME
+#define FAN_EVENT_INFO_TYPE_NEW_DFID_NAME	12
+#endif
+
 #ifndef HAVE_STRUCT_FANOTIFY_EVENT_INFO_HEADER
 struct fanotify_event_info_header {
 	uint8_t info_type;
diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c
index 1944bcbb4..5d74b9b91 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify14.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify14.c
@@ -62,6 +62,18 @@ static struct test_case_t {
 		/* FAN_REPORT_NAME without FAN_REPORT_DIR_FID is not valid */
 		FAN_CLASS_NOTIF | FAN_REPORT_FID | FAN_REPORT_NAME, 0, 0
 	},
+	{
+		/* FAN_REPORT_TARGET_FID without FAN_REPORT_FID is not valid */
+		FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_NAME, 0, 0
+	},
+	{
+		/* FAN_REPORT_TARGET_FID without FAN_REPORT_NAME is not valid */
+		FAN_CLASS_NOTIF | FAN_REPORT_TARGET_FID | FAN_REPORT_DFID_FID, 0, 0
+	},
+	{
+		/* FAN_RENAME without FAN_REPORT_NAME is not valid */
+		FAN_CLASS_NOTIF | FAN_REPORT_DFID_FID, 0, FAN_RENAME
+	},
 };
 
 static void do_test(unsigned int number)
-- 
2.35.1



More information about the ltp mailing list