fanotify: simplify handling of FAN_ONDIR
fanotify mark add/remove code jumps through hoops to avoid setting the FS_ISDIR in the commulative object mask. That was just papering over a bug in fsnotify() handling of the FS_ISDIR extra flag. This bug is now fixed, so all the hoops can be removed along with the unneeded internal flag FAN_MARK_ONDIR. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
007d1e8395
commit
a72fd224e3
@ -506,18 +506,10 @@ static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark,
|
||||
|
||||
spin_lock(&fsn_mark->lock);
|
||||
if (!(flags & FAN_MARK_IGNORED_MASK)) {
|
||||
__u32 tmask = fsn_mark->mask & ~mask;
|
||||
|
||||
if (flags & FAN_MARK_ONDIR)
|
||||
tmask &= ~FAN_ONDIR;
|
||||
|
||||
oldmask = fsn_mark->mask;
|
||||
fsn_mark->mask = tmask;
|
||||
fsn_mark->mask &= ~mask;
|
||||
} else {
|
||||
__u32 tmask = fsn_mark->ignored_mask & ~mask;
|
||||
if (flags & FAN_MARK_ONDIR)
|
||||
tmask &= ~FAN_ONDIR;
|
||||
fsn_mark->ignored_mask = tmask;
|
||||
fsn_mark->ignored_mask &= ~mask;
|
||||
}
|
||||
*destroy = !(fsn_mark->mask | fsn_mark->ignored_mask);
|
||||
spin_unlock(&fsn_mark->lock);
|
||||
@ -586,19 +578,10 @@ static __u32 fanotify_mark_add_to_mask(struct fsnotify_mark *fsn_mark,
|
||||
|
||||
spin_lock(&fsn_mark->lock);
|
||||
if (!(flags & FAN_MARK_IGNORED_MASK)) {
|
||||
__u32 tmask = fsn_mark->mask | mask;
|
||||
|
||||
if (flags & FAN_MARK_ONDIR)
|
||||
tmask |= FAN_ONDIR;
|
||||
|
||||
oldmask = fsn_mark->mask;
|
||||
fsn_mark->mask = tmask;
|
||||
fsn_mark->mask |= mask;
|
||||
} else {
|
||||
__u32 tmask = fsn_mark->ignored_mask | mask;
|
||||
if (flags & FAN_MARK_ONDIR)
|
||||
tmask |= FAN_ONDIR;
|
||||
|
||||
fsn_mark->ignored_mask = tmask;
|
||||
fsn_mark->ignored_mask |= mask;
|
||||
if (flags & FAN_MARK_IGNORED_SURV_MODIFY)
|
||||
fsn_mark->flags |= FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY;
|
||||
}
|
||||
@ -820,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 = FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD;
|
||||
u32 valid_mask = FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD | FAN_ONDIR;
|
||||
unsigned int mark_type = flags & FAN_MARK_TYPE_MASK;
|
||||
int ret;
|
||||
|
||||
@ -857,11 +840,6 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (mask & FAN_ONDIR) {
|
||||
flags |= FAN_MARK_ONDIR;
|
||||
mask &= ~FAN_ONDIR;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS))
|
||||
valid_mask |= FAN_ALL_PERM_EVENTS;
|
||||
|
||||
|
@ -4,9 +4,6 @@
|
||||
|
||||
#include <uapi/linux/fanotify.h>
|
||||
|
||||
/* not valid from userspace, only kernel internal */
|
||||
#define FAN_MARK_ONDIR 0x80000000
|
||||
|
||||
#define FAN_GROUP_FLAG(group, flag) \
|
||||
((group)->fanotify_data.flags & (flag))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user