diff options
author | Amir Goldstein <amir73il@gmail.com> | 2018-10-03 17:25:33 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2018-10-04 07:28:02 -0400 |
commit | 007d1e8395eaa59b0e7ad9eb2b53a40859446a88 (patch) | |
tree | ba3cafc48e79f3489f5faccfd5935cf2141f76f9 | |
parent | b723a7911d028fb55f67a63c4c4d895f72e059d4 (diff) |
fsnotify: generalize handling of extra event flags
FS_EVENT_ON_CHILD gets a special treatment in fsnotify() because it is
not a flag specifying an event type, but rather an extra flags that may
be reported along with another event and control the handling of the
event by the backend.
FS_ISDIR is also an "extra flag" and not an "event type" and therefore
desrves the same treatment. With inotify/dnotify backends it was never
possible to set FS_ISDIR in mark masks, so it did not matter.
With fanotify backend, mark adding code jumps through hoops to avoid
setting the FS_ISDIR in the commulative object mask.
Separate the constant ALL_FSNOTIFY_EVENTS to ALL_FSNOTIFY_FLAGS and
ALL_FSNOTIFY_EVENTS, so the latter can be used to test for specific
event types.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | fs/notify/fsnotify.c | 7 | ||||
-rw-r--r-- | include/linux/fsnotify_backend.h | 9 |
2 files changed, 10 insertions, 6 deletions
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 422fbc6dffde..7391a02bf723 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c | |||
@@ -196,7 +196,7 @@ static int send_to_group(struct inode *to_tell, | |||
196 | struct fsnotify_iter_info *iter_info) | 196 | struct fsnotify_iter_info *iter_info) |
197 | { | 197 | { |
198 | struct fsnotify_group *group = NULL; | 198 | struct fsnotify_group *group = NULL; |
199 | __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); | 199 | __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); |
200 | __u32 marks_mask = 0; | 200 | __u32 marks_mask = 0; |
201 | __u32 marks_ignored_mask = 0; | 201 | __u32 marks_ignored_mask = 0; |
202 | struct fsnotify_mark *mark; | 202 | struct fsnotify_mark *mark; |
@@ -329,8 +329,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, | |||
329 | struct mount *mnt = NULL; | 329 | struct mount *mnt = NULL; |
330 | __u32 mnt_or_sb_mask = 0; | 330 | __u32 mnt_or_sb_mask = 0; |
331 | int ret = 0; | 331 | int ret = 0; |
332 | /* global tests shouldn't care about events on child only the specific event */ | 332 | __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); |
333 | __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); | ||
334 | 333 | ||
335 | if (data_is == FSNOTIFY_EVENT_PATH) { | 334 | if (data_is == FSNOTIFY_EVENT_PATH) { |
336 | mnt = real_mount(((const struct path *)data)->mnt); | 335 | mnt = real_mount(((const struct path *)data)->mnt); |
@@ -396,7 +395,7 @@ static __init int fsnotify_init(void) | |||
396 | { | 395 | { |
397 | int ret; | 396 | int ret; |
398 | 397 | ||
399 | BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 23); | 398 | BUG_ON(hweight32(ALL_FSNOTIFY_BITS) != 23); |
400 | 399 | ||
401 | ret = init_srcu_struct(&fsnotify_mark_srcu); | 400 | ret = init_srcu_struct(&fsnotify_mark_srcu); |
402 | if (ret) | 401 | if (ret) |
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 8e91341cbd8a..135b973e44d1 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
@@ -68,15 +68,20 @@ | |||
68 | 68 | ||
69 | #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM) | 69 | #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM) |
70 | 70 | ||
71 | /* Events that can be reported to backends */ | ||
71 | #define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \ | 72 | #define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \ |
72 | FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \ | 73 | FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \ |
73 | FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \ | 74 | FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \ |
74 | FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \ | 75 | FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \ |
75 | FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \ | 76 | FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \ |
76 | FS_OPEN_PERM | FS_ACCESS_PERM | FS_EXCL_UNLINK | \ | 77 | FS_OPEN_PERM | FS_ACCESS_PERM | FS_DN_RENAME) |
77 | FS_ISDIR | FS_IN_ONESHOT | FS_DN_RENAME | \ | 78 | |
79 | /* Extra flags that may be reported with event or control handling of events */ | ||
80 | #define ALL_FSNOTIFY_FLAGS (FS_EXCL_UNLINK | FS_ISDIR | FS_IN_ONESHOT | \ | ||
78 | FS_DN_MULTISHOT | FS_EVENT_ON_CHILD) | 81 | FS_DN_MULTISHOT | FS_EVENT_ON_CHILD) |
79 | 82 | ||
83 | #define ALL_FSNOTIFY_BITS (ALL_FSNOTIFY_EVENTS | ALL_FSNOTIFY_FLAGS) | ||
84 | |||
80 | struct fsnotify_group; | 85 | struct fsnotify_group; |
81 | struct fsnotify_event; | 86 | struct fsnotify_event; |
82 | struct fsnotify_mark; | 87 | struct fsnotify_mark; |