linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 6/8] fanotify: add BUILD_BUG_ON() to count the bits of fanotify constants
Date: Thu,  4 Oct 2018 00:25:37 +0300	[thread overview]
Message-ID: <20181003212539.2384-7-amir73il@gmail.com> (raw)
In-Reply-To: <20181003212539.2384-1-amir73il@gmail.com>

Also define the FANOTIFY_EVENT_FLAGS consisting of the extra flags
FAN_ONDIR and FAN_ON_CHILD.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/notify/fanotify/fanotify.c      | 2 ++
 fs/notify/fanotify/fanotify_user.c | 5 ++++-
 include/linux/fanotify.h           | 8 ++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 03498eb995be..361e3a0a445c 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -205,6 +205,8 @@ static int fanotify_handle_event(struct fsnotify_group *group,
 	BUILD_BUG_ON(FAN_ACCESS_PERM != FS_ACCESS_PERM);
 	BUILD_BUG_ON(FAN_ONDIR != FS_ISDIR);
 
+	BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 10);
+
 	if (!fanotify_should_send_event(iter_info, mask, data, data_type))
 		return 0;
 
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 530e5e486105..14594e491d2b 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -803,7 +803,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
 	struct fsnotify_group *group;
 	struct fd f;
 	struct path path;
-	u32 valid_mask = FANOTIFY_EVENTS | FAN_EVENT_ON_CHILD | FAN_ONDIR;
+	u32 valid_mask = FANOTIFY_EVENTS | FANOTIFY_EVENT_FLAGS;
 	unsigned int mark_type = flags & FANOTIFY_MARK_TYPE_BITS;
 	int ret;
 
@@ -944,6 +944,9 @@ COMPAT_SYSCALL_DEFINE6(fanotify_mark,
  */
 static int __init fanotify_user_setup(void)
 {
+	BUILD_BUG_ON(HWEIGHT32(FANOTIFY_INIT_FLAGS) != 6);
+	BUILD_BUG_ON(HWEIGHT32(FANOTIFY_MARK_FLAGS) != 9);
+
 	fanotify_mark_cache = KMEM_CACHE(fsnotify_mark,
 					 SLAB_PANIC|SLAB_ACCOUNT);
 	fanotify_event_cachep = KMEM_CACHE(fanotify_event_info, SLAB_PANIC);
diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h
index 4519b0988afe..afddd7e0d5a1 100644
--- a/include/linux/fanotify.h
+++ b/include/linux/fanotify.h
@@ -41,11 +41,19 @@
 /* Events that require a permission response from user */
 #define FANOTIFY_PERM_EVENTS	(FAN_OPEN_PERM | FAN_ACCESS_PERM)
 
+/* Extra flags that may be reported with event or control handling of events */
+#define FANOTIFY_EVENT_FLAGS	(FAN_EVENT_ON_CHILD | FAN_ONDIR)
+
 /* Events that may be reported to user */
 #define FANOTIFY_OUTGOING_EVENTS	(FANOTIFY_EVENTS | \
 					 FANOTIFY_PERM_EVENTS | \
 					 FAN_Q_OVERFLOW)
 
+#define ALL_FANOTIFY_EVENT_BITS		(FANOTIFY_EVENTS | \
+					 FANOTIFY_PERM_EVENTS | \
+					 FANOTIFY_EVENT_FLAGS | \
+					 FANOTIFY_OUTGOING_EVENTS)
+
 /* Do not use these old uapi constants internally */
 #undef FAN_ALL_CLASS_BITS
 #undef FAN_ALL_INIT_FLAGS
-- 
2.17.1

  parent reply	other threads:[~2018-10-04  4:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03 21:25 [PATCH v3 0/8] New fanotify event info API Amir Goldstein
2018-10-03 21:25 ` [PATCH v3 1/8] fanotify: fix collision of internal and uapi mark flags Amir Goldstein
2018-10-03 21:25 ` [PATCH v3 2/8] fsnotify: generalize handling of extra event flags Amir Goldstein
2018-10-03 21:25 ` [PATCH v3 3/8] fanotify: simplify handling of FAN_ONDIR Amir Goldstein
2018-10-03 21:25 ` [PATCH v3 4/8] fanotify: deprecate uapi FAN_ALL_* constants Amir Goldstein
2018-10-03 21:25 ` [PATCH v3 5/8] fsnotify: convert runtime BUG_ON() to BUILD_BUG_ON() Amir Goldstein
2018-10-03 21:25 ` Amir Goldstein [this message]
2018-10-04  8:41   ` [PATCH v3 6/8] fanotify: add BUILD_BUG_ON() to count the bits of fanotify constants Jan Kara
2018-10-04 10:24     ` Amir Goldstein
2018-10-03 21:25 ` [PATCH v3 7/8] fanotify: support reporting thread id instead of process id Amir Goldstein
2018-10-04  8:46   ` Jan Kara
2018-10-04 10:27     ` Amir Goldstein
2018-10-11 10:16   ` Jan Kara
2018-10-12  2:43     ` Nixiaoming
2018-10-16 12:06       ` Jan Kara
2018-10-03 21:25 ` [PATCH v3 8/8] fsnotify: optimize away srcu_read_lock() for events on directories Amir Goldstein
2018-10-04  9:09   ` Jan Kara
2018-10-04 10:30     ` Amir Goldstein
2018-10-04 11:26       ` Jan Kara
2018-10-04 22:05         ` Amir Goldstein

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=20181003212539.2384-7-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).