[LTP] [PATCH 1/3] fanotify10: Use named initializers

Jan Kara
2022-11-15T12:48:28Z

Convert the testcase to use named initializers instead of anonymous
ones.

Signed-off-by: Jan Kara <jack@suse.cz>
---
.../kernel/syscalls/fanotify/fanotify10.c | 408 +++++++++++-------
1 file changed, 249 insertions(+), 159 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
index ca0d8a9e4a4a..6f21094bed2c 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify10.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
@@ -133,227 +133,317 @@ static struct tcase {
unsigned long long expected_mask_without_ignore;
} tcases[] = {
{
- "ignore mount events created on a specific file",
- MOUNT_PATH, FANOTIFY_MOUNT,
- FILE_MNT2, FANOTIFY_INODE,
- 0,
- FILE_PATH, 0, FAN_OPEN
+ .tname = "ignore mount events created on a specific file",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_MOUNT,
+ .ignore_path = FILE_MNT2,
+ .ignore_mark_type = FANOTIFY_INODE,
+ .event_path = FILE_PATH,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "ignore exec mount events created on a specific file",
- MOUNT_PATH, FANOTIFY_MOUNT,
- FILE_EXEC_PATH2, FANOTIFY_INODE,
- 0,
- FILE_EXEC_PATH, FAN_OPEN_EXEC, FAN_OPEN | FAN_OPEN_EXEC
+ .tname = "ignore exec mount events created on a specific file",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_MOUNT,
+ .ignore_path = FILE_EXEC_PATH2,
+ .ignore_mark_type = FANOTIFY_INODE,
+ .event_path = FILE_EXEC_PATH,
+ .expected_mask_with_ignore = FAN_OPEN_EXEC,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_OPEN_EXEC
},
{
- "don't ignore mount events created on another file",
- MOUNT_PATH, FANOTIFY_MOUNT,
- FILE_PATH, FANOTIFY_INODE,
- 0,
- FILE2_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore mount events created on another file",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_MOUNT,
+ .ignore_path = FILE_PATH,
+ .ignore_mark_type = FANOTIFY_INODE,
+ .event_path = FILE2_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore exec mount events created on another file",
- MOUNT_PATH, FANOTIFY_MOUNT,
- FILE_EXEC_PATH, FANOTIFY_INODE,
- 0,
- FILE2_EXEC_PATH, FAN_OPEN | FAN_OPEN_EXEC,
- FAN_OPEN | FAN_OPEN_EXEC
+ .tname = "don't ignore exec mount events created on another file",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_MOUNT,
+ .ignore_path = FILE_EXEC_PATH,
+ .ignore_mark_type = FANOTIFY_INODE,
+ .event_path = FILE2_EXEC_PATH,
+ .expected_mask_with_ignore = FAN_OPEN | FAN_OPEN_EXEC,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_OPEN_EXEC
},
{
- "ignore inode events created on a specific mount point",
- FILE_PATH, FANOTIFY_INODE,
- MNT2_PATH, FANOTIFY_MOUNT,
- 0,
- FILE_MNT2, 0, FAN_OPEN
+ .tname = "ignore inode events created on a specific mount point",
+ .mark_path = FILE_PATH,
+ .mark_type = FANOTIFY_INODE,
+ .ignore_path = MNT2_PATH,
+ .ignore_mark_type = FANOTIFY_MOUNT,
+ .event_path = FILE_MNT2,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "ignore exec inode events created on a specific mount point",
- FILE_EXEC_PATH, FANOTIFY_INODE,
- MNT2_PATH, FANOTIFY_MOUNT,
- 0,
- FILE_EXEC_PATH2, FAN_OPEN_EXEC, FAN_OPEN | FAN_OPEN_EXEC
+ .tname = "ignore exec inode events created on a specific mount point",
+ .mark_path = FILE_EXEC_PATH,
+ .mark_type = FANOTIFY_INODE,
+ .ignore_path = MNT2_PATH,
+ .ignore_mark_type = FANOTIFY_MOUNT,
+ .event_path = FILE_EXEC_PATH2,
+ .expected_mask_with_ignore = FAN_OPEN_EXEC,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_OPEN_EXEC
},
{
- "don't ignore inode events created on another mount point",
- FILE_MNT2, FANOTIFY_INODE,
- MNT2_PATH, FANOTIFY_MOUNT,
- 0,
- FILE_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore inode events created on another mount point",
+ .mark_path = FILE_MNT2,
+ .mark_type = FANOTIFY_INODE,
+ .ignore_path = MNT2_PATH,
+ .ignore_mark_type = FANOTIFY_MOUNT,
+ .event_path = FILE_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore exec inode events created on another mount point",
- FILE_EXEC_PATH2, FANOTIFY_INODE,
- MNT2_PATH, FANOTIFY_MOUNT,
- 0,
- FILE_EXEC_PATH, FAN_OPEN | FAN_OPEN_EXEC,
- FAN_OPEN | FAN_OPEN_EXEC
+ .tname = "don't ignore exec inode events created on another mount point",
+ .mark_path = FILE_EXEC_PATH2,
+ .mark_type = FANOTIFY_INODE,
+ .ignore_path = MNT2_PATH,
+ .ignore_mark_type = FANOTIFY_MOUNT,
+ .event_path = FILE_EXEC_PATH,
+ .expected_mask_with_ignore = FAN_OPEN | FAN_OPEN_EXEC,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_OPEN_EXEC
},
{
- "ignore fs events created on a specific file",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- FILE_PATH, FANOTIFY_INODE,
- 0,
- FILE_PATH, 0, FAN_OPEN
+ .tname = "ignore fs events created on a specific file",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = FILE_PATH,
+ .ignore_mark_type = FANOTIFY_INODE,
+ .event_path = FILE_PATH,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "ignore exec fs events created on a specific file",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- FILE_EXEC_PATH, FANOTIFY_INODE,
- 0,
- FILE_EXEC_PATH, FAN_OPEN_EXEC, FAN_OPEN | FAN_OPEN_EXEC
+ .tname = "ignore exec fs events created on a specific file",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = FILE_EXEC_PATH,
+ .ignore_mark_type = FANOTIFY_INODE,
+ .event_path = FILE_EXEC_PATH,
+ .expected_mask_with_ignore = FAN_OPEN_EXEC,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_OPEN_EXEC
},
{
- "don't ignore mount events created on another file",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- FILE_PATH, FANOTIFY_INODE,
- 0,
- FILE2_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore mount events created on another file",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = FILE_PATH,
+ .ignore_mark_type = FANOTIFY_INODE,
+ .event_path = FILE2_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore exec mount events created on another file",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- FILE_EXEC_PATH, FANOTIFY_INODE,
- 0,
- FILE2_EXEC_PATH, FAN_OPEN | FAN_OPEN_EXEC,
- FAN_OPEN | FAN_OPEN_EXEC
+ .tname = "don't ignore exec mount events created on another file",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = FILE_EXEC_PATH,
+ .ignore_mark_type = FANOTIFY_INODE,
+ .event_path = FILE2_EXEC_PATH,
+ .expected_mask_with_ignore = FAN_OPEN | FAN_OPEN_EXEC,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_OPEN_EXEC
},
{
- "ignore fs events created on a specific mount point",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- MNT2_PATH, FANOTIFY_MOUNT,
- 0,
- FILE_MNT2, 0, FAN_OPEN
+ .tname = "ignore fs events created on a specific mount point",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = MNT2_PATH,
+ .ignore_mark_type = FANOTIFY_MOUNT,
+ .event_path = FILE_MNT2,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "ignore exec fs events created on a specific mount point",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- MNT2_PATH, FANOTIFY_MOUNT,
- 0,
- FILE_EXEC_PATH2, FAN_OPEN_EXEC, FAN_OPEN | FAN_OPEN_EXEC
+ .tname = "ignore exec fs events created on a specific mount point",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = MNT2_PATH,
+ .ignore_mark_type = FANOTIFY_MOUNT,
+ .event_path = FILE_EXEC_PATH2,
+ .expected_mask_with_ignore = FAN_OPEN_EXEC,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_OPEN_EXEC
},
{
- "don't ignore fs events created on another mount point",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- MNT2_PATH, FANOTIFY_MOUNT,
- 0,
- FILE_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore fs events created on another mount point",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = MNT2_PATH,
+ .ignore_mark_type = FANOTIFY_MOUNT,
+ .event_path = FILE_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore exec fs events created on another mount point",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- MNT2_PATH, FANOTIFY_MOUNT,
- 0,
- FILE_EXEC_PATH, FAN_OPEN | FAN_OPEN_EXEC,
- FAN_OPEN | FAN_OPEN_EXEC
+ .tname = "don't ignore exec fs events created on another mount point",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = MNT2_PATH,
+ .ignore_mark_type = FANOTIFY_MOUNT,
+ .event_path = FILE_EXEC_PATH,
+ .expected_mask_with_ignore = FAN_OPEN | FAN_OPEN_EXEC,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_OPEN_EXEC
},
{
- "ignore child exec events created on a specific mount point",
- MOUNT_PATH, FANOTIFY_PARENT,
- MOUNT_PATH, FANOTIFY_MOUNT,
- 0,
- FILE_EXEC_PATH, FAN_OPEN_EXEC, FAN_OPEN | FAN_OPEN_EXEC
+ .tname = "ignore child exec events created on a specific mount point",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_PARENT,
+ .ignore_path = MOUNT_PATH,
+ .ignore_mark_type = FANOTIFY_MOUNT,
+ .event_path = FILE_EXEC_PATH,
+ .expected_mask_with_ignore = FAN_OPEN_EXEC,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_OPEN_EXEC
},
{
- "ignore events on children of directory created on a specific file",
- DIR_PATH, FANOTIFY_PARENT,
- DIR_PATH, FANOTIFY_PARENT,
- FAN_EVENT_ON_CHILD,
- FILE_PATH, 0, FAN_OPEN
+ .tname = "ignore events on children of directory created on a specific file",
+ .mark_path = DIR_PATH,
+ .mark_type = FANOTIFY_PARENT,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .ignored_flags = FAN_EVENT_ON_CHILD,
+ .event_path = FILE_PATH,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "ignore events on file created inside a parent watching children",
- FILE_PATH, FANOTIFY_INODE,
- DIR_PATH, FANOTIFY_PARENT,
- FAN_EVENT_ON_CHILD,
- FILE_PATH, 0, FAN_OPEN
+ .tname = "ignore events on file created inside a parent watching children",
+ .mark_path = FILE_PATH,
+ .mark_type = FANOTIFY_INODE,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .ignored_flags = FAN_EVENT_ON_CHILD,
+ .event_path = FILE_PATH,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore events on file created inside a parent not watching children",
- FILE_PATH, FANOTIFY_INODE,
- DIR_PATH, FANOTIFY_PARENT,
- 0,
- FILE_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore events on file created inside a parent not watching children",
+ .mark_path = FILE_PATH,
+ .mark_type = FANOTIFY_INODE,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .event_path = FILE_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "ignore mount events created inside a parent watching children",
- FILE_PATH, FANOTIFY_MOUNT,
- DIR_PATH, FANOTIFY_PARENT,
- FAN_EVENT_ON_CHILD,
- FILE_PATH, 0, FAN_OPEN
+ .tname = "ignore mount events created inside a parent watching children",
+ .mark_path = FILE_PATH,
+ .mark_type = FANOTIFY_MOUNT,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .ignored_flags = FAN_EVENT_ON_CHILD,
+ .event_path = FILE_PATH,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore mount events created inside a parent not watching children",
- FILE_PATH, FANOTIFY_MOUNT,
- DIR_PATH, FANOTIFY_PARENT,
- 0,
- FILE_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore mount events created inside a parent not watching children",
+ .mark_path = FILE_PATH,
+ .mark_type = FANOTIFY_MOUNT,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .event_path = FILE_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "ignore fs events created inside a parent watching children",
- FILE_PATH, FANOTIFY_FILESYSTEM,
- DIR_PATH, FANOTIFY_PARENT,
- FAN_EVENT_ON_CHILD,
- FILE_PATH, 0, FAN_OPEN
+ .tname = "ignore fs events created inside a parent watching children",
+ .mark_path = FILE_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .ignored_flags = FAN_EVENT_ON_CHILD,
+ .event_path = FILE_PATH,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore fs events created inside a parent not watching children",
- FILE_PATH, FANOTIFY_FILESYSTEM,
- DIR_PATH, FANOTIFY_PARENT,
- 0,
- FILE_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore fs events created inside a parent not watching children",
+ .mark_path = FILE_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .event_path = FILE_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
/* Evictable ignore mark test cases */
{
- "don't ignore mount events created on file with evicted ignore mark",
- MOUNT_PATH, FANOTIFY_MOUNT,
- FILE_PATH, FANOTIFY_EVICTABLE,
- 0,
- FILE_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore mount events created on file with evicted ignore mark",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_MOUNT,
+ .ignore_path = FILE_PATH,
+ .ignore_mark_type = FANOTIFY_EVICTABLE,
+ .event_path = FILE_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore fs events created on a file with evicted ignore mark",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- FILE_PATH, FANOTIFY_EVICTABLE,
- 0,
- FILE_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore fs events created on a file with evicted ignore mark",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = FILE_PATH,
+ .ignore_mark_type = FANOTIFY_EVICTABLE,
+ .event_path = FILE_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore mount events created inside a parent with evicted ignore mark",
- MOUNT_PATH, FANOTIFY_MOUNT,
- DIR_PATH, FANOTIFY_EVICTABLE,
- FAN_EVENT_ON_CHILD,
- FILE_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore mount events created inside a parent with evicted ignore mark",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_MOUNT,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_EVICTABLE,
+ .ignored_flags = FAN_EVENT_ON_CHILD,
+ .event_path = FILE_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
{
- "don't ignore fs events created inside a parent with evicted ignore mark",
- MOUNT_PATH, FANOTIFY_FILESYSTEM,
- DIR_PATH, FANOTIFY_EVICTABLE,
- FAN_EVENT_ON_CHILD,
- FILE_PATH, FAN_OPEN, FAN_OPEN
+ .tname = "don't ignore fs events created inside a parent with evicted ignore mark",
+ .mark_path = MOUNT_PATH,
+ .mark_type = FANOTIFY_FILESYSTEM,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_EVICTABLE,
+ .ignored_flags = FAN_EVENT_ON_CHILD,
+ .event_path = FILE_PATH,
+ .expected_mask_with_ignore = FAN_OPEN,
+ .expected_mask_without_ignore = FAN_OPEN
},
/* FAN_MARK_IGNORE specific test cases */
{
- "ignore events on subdir inside a parent watching subdirs",
- SUBDIR_PATH, FANOTIFY_SUBDIR,
- DIR_PATH, FANOTIFY_PARENT,
- FAN_EVENT_ON_CHILD | FAN_ONDIR,
- SUBDIR_PATH, 0, FAN_OPEN | FAN_ONDIR
+ .tname = "ignore events on subdir inside a parent watching subdirs",
+ .mark_path = SUBDIR_PATH,
+ .mark_type = FANOTIFY_SUBDIR,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .ignored_flags = FAN_EVENT_ON_CHILD | FAN_ONDIR,
+ .event_path = SUBDIR_PATH,
+ .expected_mask_with_ignore = 0,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_ONDIR
},
{
- "don't ignore events on subdir inside a parent not watching children",
- SUBDIR_PATH, FANOTIFY_SUBDIR,
- DIR_PATH, FANOTIFY_PARENT,
- FAN_ONDIR,
- SUBDIR_PATH, FAN_OPEN | FAN_ONDIR, FAN_OPEN | FAN_ONDIR
+ .tname = "don't ignore events on subdir inside a parent not watching children",
+ .mark_path = SUBDIR_PATH,
+ .mark_type = FANOTIFY_SUBDIR,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .ignored_flags = FAN_ONDIR,
+ .event_path = SUBDIR_PATH,
+ .expected_mask_with_ignore = FAN_OPEN | FAN_ONDIR,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_ONDIR
},
{
- "don't ignore events on subdir inside a parent watching non-dir children",
- SUBDIR_PATH, FANOTIFY_SUBDIR,
- DIR_PATH, FANOTIFY_PARENT,
- FAN_EVENT_ON_CHILD,
- SUBDIR_PATH, FAN_OPEN | FAN_ONDIR, FAN_OPEN | FAN_ONDIR
+ .tname = "don't ignore events on subdir inside a parent watching non-dir children",
+ .mark_path = SUBDIR_PATH,
+ .mark_type = FANOTIFY_SUBDIR,
+ .ignore_path = DIR_PATH,
+ .ignore_mark_type = FANOTIFY_PARENT,
+ .ignored_flags = FAN_EVENT_ON_CHILD,
+ .event_path = SUBDIR_PATH,
+ .expected_mask_with_ignore = FAN_OPEN | FAN_ONDIR,
+ .expected_mask_without_ignore = FAN_OPEN | FAN_ONDIR
},
};

--
2.35.3