From: Amir Goldstein <amir73il@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 5/5] syscalls/fanotify10: add tests for FAN_MARK_FILESYSTEM and ignore mask
Date: Fri, 16 Nov 2018 08:51:19 +0200 [thread overview]
Message-ID: <20181116065119.6912-6-amir73il@gmail.com> (raw)
In-Reply-To: <20181116065119.6912-1-amir73il@gmail.com>
A watch with FAN_MARK_FILESYSTEM should ignore events that were
generated on files whose inode have an ignore mask and ignore events
generated on a mount that has a mark with ignore mask.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
.../kernel/syscalls/fanotify/fanotify10.c | 40 ++++++++++++++++++-
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
index 2b96de2f1..820c50a8a 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify10.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
@@ -66,11 +66,13 @@ static int bind_mount_created;
enum {
FANOTIFY_INODE,
FANOTIFY_MOUNT,
+ FANOTIFY_FILESYSTEM,
};
static struct fanotify_mark_type fanotify_mark_types[] = {
INIT_FANOTIFY_MARK_TYPE(INODE),
INIT_FANOTIFY_MARK_TYPE(MOUNT),
+ INIT_FANOTIFY_MARK_TYPE(FILESYSTEM),
};
static struct tcase {
@@ -106,9 +108,33 @@ static struct tcase {
MNT2_PATH, FANOTIFY_MOUNT,
FILE_PATH, 1
},
+ {
+ "ignore fs events created on a specific file",
+ MOUNT_PATH, FANOTIFY_FILESYSTEM,
+ FILE_PATH, FANOTIFY_INODE,
+ FILE_PATH, 0
+ },
+ {
+ "don't ignore mount events created on another file",
+ MOUNT_PATH, FANOTIFY_FILESYSTEM,
+ FILE_PATH, FANOTIFY_INODE,
+ FILE2_PATH, 1
+ },
+ {
+ "ignore fs events created on a specific mount point",
+ MOUNT_PATH, FANOTIFY_FILESYSTEM,
+ MNT2_PATH, FANOTIFY_MOUNT,
+ FILE_MNT2, 0
+ },
+ {
+ "don't ignore fs events created on another mount point",
+ MOUNT_PATH, FANOTIFY_FILESYSTEM,
+ MNT2_PATH, FANOTIFY_MOUNT,
+ FILE_PATH, 1
+ },
};
-static void create_fanotify_groups(unsigned int n)
+static int create_fanotify_groups(unsigned int n)
{
struct tcase *tc = &tcases[n];
struct fanotify_mark_type *mark, *ignore_mark;
@@ -129,6 +155,13 @@ static void create_fanotify_groups(unsigned int n)
FAN_MARK_ADD | mark->flag,
FAN_OPEN, AT_FDCWD, tc->mark_path);
if (ret < 0) {
+ if (errno == EINVAL &&
+ tc->mark_type == FANOTIFY_FILESYSTEM) {
+ tst_res(TCONF,
+ "FAN_MARK_FILESYSTEM not "
+ "supported in kernel?");
+ return -1;
+ }
tst_brk(TBROK | TERRNO,
"fanotify_mark(%d, FAN_MARK_ADD | %s,"
"FAN_OPEN, AT_FDCWD, %s) failed",
@@ -155,6 +188,7 @@ static void create_fanotify_groups(unsigned int n)
}
}
}
+ return 0;
}
static void cleanup_fanotify_groups(void)
@@ -198,7 +232,8 @@ static void test_fanotify(unsigned int n)
tst_res(TINFO, "Test #%d: %s", n, tc->tname);
- create_fanotify_groups(n);
+ if (create_fanotify_groups(n) != 0)
+ goto cleanup;
mark = &fanotify_mark_types[tc->mark_type];
ignore_mark = &fanotify_mark_types[tc->ignore_mark_type];
@@ -268,6 +303,7 @@ static void test_fanotify(unsigned int n)
}
}
}
+cleanup:
cleanup_fanotify_groups();
}
--
2.17.1
next prev parent reply other threads:[~2018-11-16 6:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-16 6:51 [LTP] [PATCH 0/5] fanotify filesystem mark tests Amir Goldstein
2018-11-16 6:51 ` [LTP] [PATCH 1/5] syscalls/fanotify01: check events also on mountpoint mark Amir Goldstein
2018-11-21 12:01 ` Cyril Hrubis
2018-11-21 16:18 ` Amir Goldstein
2018-11-22 16:06 ` Cyril Hrubis
2018-11-22 16:57 ` Amir Goldstein
2018-11-16 6:51 ` [LTP] [PATCH 2/5] syscalls/fanotify03: check permission " Amir Goldstein
2018-11-21 12:26 ` Cyril Hrubis
2018-11-16 6:51 ` [LTP] [PATCH 3/5] syscalls/fanotify01: add test for FAN_MARK_FILESYSTEM events Amir Goldstein
2018-11-21 13:00 ` Cyril Hrubis
2018-11-16 6:51 ` [LTP] [PATCH 4/5] syscalls/fanotify03: add test for FAN_MARK_FILESYSTEM permission events Amir Goldstein
2018-11-21 13:14 ` Cyril Hrubis
2018-11-21 16:36 ` Amir Goldstein
2018-11-21 17:10 ` Amir Goldstein
2018-11-22 16:03 ` Cyril Hrubis
2018-11-16 6:51 ` Amir Goldstein [this message]
2018-11-21 13:27 ` [LTP] [PATCH 5/5] syscalls/fanotify10: add tests for FAN_MARK_FILESYSTEM and ignore mask Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181116065119.6912-6-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox