All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] inotify: add support watch open exec event
@ 2020-09-14 17:27 Weiping Zhang
  2020-09-15  7:08 ` Jan Kara
  0 siblings, 1 reply; 10+ messages in thread
From: Weiping Zhang @ 2020-09-14 17:27 UTC (permalink / raw)
  To: jack, amir73il; +Cc: linux-fsdevel

Now the IN_OPEN event can report all open events for a file, but it can
not distinguish if the file was opened for execute or read/write.
This patch add a new event IN_OPEN_EXEC to support that. If user only
want to monitor a file was opened for execute, they can pass a more
precise event IN_OPEN_EXEC to inotify_add_watch.

Signed-off-by: Weiping Zhang <zhangweiping@didiglobal.com>
---
 fs/notify/inotify/inotify_user.c | 3 ++-
 include/linux/inotify.h          | 2 +-
 include/uapi/linux/inotify.h     | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 186722ba3894..eb42d11a9988 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -819,8 +819,9 @@ static int __init inotify_user_setup(void)
 	BUILD_BUG_ON(IN_EXCL_UNLINK != FS_EXCL_UNLINK);
 	BUILD_BUG_ON(IN_ISDIR != FS_ISDIR);
 	BUILD_BUG_ON(IN_ONESHOT != FS_IN_ONESHOT);
+	BUILD_BUG_ON(IN_OPEN_EXEC != FS_OPEN_EXEC);
 
-	BUILD_BUG_ON(HWEIGHT32(ALL_INOTIFY_BITS) != 22);
+	BUILD_BUG_ON(HWEIGHT32(ALL_INOTIFY_BITS) != 23);
 
 	inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark,
 					       SLAB_PANIC|SLAB_ACCOUNT);
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index 6a24905f6e1e..88fc82c8cf2a 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -15,7 +15,7 @@ extern struct ctl_table inotify_table[]; /* for sysctl */
 #define ALL_INOTIFY_BITS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
 			  IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
 			  IN_MOVED_TO | IN_CREATE | IN_DELETE | \
-			  IN_DELETE_SELF | IN_MOVE_SELF | IN_UNMOUNT | \
+			  IN_DELETE_SELF | IN_MOVE_SELF | IN_OPEN_EXEC | IN_UNMOUNT | \
 			  IN_Q_OVERFLOW | IN_IGNORED | IN_ONLYDIR | \
 			  IN_DONT_FOLLOW | IN_EXCL_UNLINK | IN_MASK_ADD | \
 			  IN_MASK_CREATE | IN_ISDIR | IN_ONESHOT)
diff --git a/include/uapi/linux/inotify.h b/include/uapi/linux/inotify.h
index 884b4846b630..f19ea046cc87 100644
--- a/include/uapi/linux/inotify.h
+++ b/include/uapi/linux/inotify.h
@@ -39,6 +39,7 @@ struct inotify_event {
 #define IN_DELETE		0x00000200	/* Subfile was deleted */
 #define IN_DELETE_SELF		0x00000400	/* Self was deleted */
 #define IN_MOVE_SELF		0x00000800	/* Self was moved */
+#define IN_OPEN_EXEC		0x00001000	/* File was opened */
 
 /* the following are legal events.  they are sent as needed to any watch */
 #define IN_UNMOUNT		0x00002000	/* Backing fs was unmounted */
@@ -66,7 +67,7 @@ struct inotify_event {
 #define IN_ALL_EVENTS	(IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
 			 IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
 			 IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
-			 IN_MOVE_SELF)
+			 IN_MOVE_SELF | IN_OPEN_EXEC)
 
 /* Flags for sys_inotify_init1.  */
 #define IN_CLOEXEC O_CLOEXEC
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-10-02  9:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 17:27 [RFC PATCH] inotify: add support watch open exec event Weiping Zhang
2020-09-15  7:08 ` Jan Kara
2020-09-15  8:33   ` Amir Goldstein
2020-09-15 12:09     ` Weiping Zhang
2020-10-01 11:00     ` Jan Kara
2020-10-01 13:08       ` FAN_UNPRIVILEGED Amir Goldstein
2020-10-02  8:27         ` FAN_UNPRIVILEGED Jan Kara
2020-10-02  9:06           ` FAN_UNPRIVILEGED Amir Goldstein
2020-10-02  9:51             ` FAN_UNPRIVILEGED Jan Kara
2020-10-01 13:23       ` pairing FAN_MOVED_FROM/FAN_MOVED_TO events Amir Goldstein

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.