fanotify: remove fanotify.h declarations
fanotify_mark_validate functions are all needlessly declared in headers as static inlines. Instead just do the checks where they are needed for code readability. Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
Родитель
f3640192c0
Коммит
88380fe66e
|
@ -6,31 +6,6 @@
|
||||||
|
|
||||||
extern const struct fsnotify_ops fanotify_fsnotify_ops;
|
extern const struct fsnotify_ops fanotify_fsnotify_ops;
|
||||||
|
|
||||||
static inline bool fanotify_mark_flags_valid(unsigned int flags)
|
|
||||||
{
|
|
||||||
/* must be either and add or a remove */
|
|
||||||
if (!(flags & (FAN_MARK_ADD | FAN_MARK_REMOVE)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* cannot be both add and remove */
|
|
||||||
if ((flags & FAN_MARK_ADD) &&
|
|
||||||
(flags & FAN_MARK_REMOVE))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* cannot have more flags than we know about */
|
|
||||||
if (flags & ~FAN_ALL_MARK_FLAGS)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool fanotify_mask_valid(__u32 mask)
|
|
||||||
{
|
|
||||||
if (mask & ~((__u32)FAN_ALL_INCOMING_EVENTS))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline __u32 fanotify_outgoing_mask(__u32 mask)
|
static inline __u32 fanotify_outgoing_mask(__u32 mask)
|
||||||
{
|
{
|
||||||
return mask & FAN_ALL_OUTGOING_EVENTS;
|
return mask & FAN_ALL_OUTGOING_EVENTS;
|
||||||
|
|
|
@ -430,20 +430,6 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool fanotify_mark_validate_input(int flags,
|
|
||||||
__u32 mask)
|
|
||||||
{
|
|
||||||
pr_debug("%s: flags=%x mask=%x\n", __func__, flags, mask);
|
|
||||||
|
|
||||||
/* are flags valid of this operation? */
|
|
||||||
if (!fanotify_mark_flags_valid(flags))
|
|
||||||
return false;
|
|
||||||
/* is the mask valid? */
|
|
||||||
if (!fanotify_mask_valid(mask))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fanotify syscalls */
|
/* fanotify syscalls */
|
||||||
SYSCALL_DEFINE3(fanotify_init, unsigned int, flags, unsigned int, event_f_flags,
|
SYSCALL_DEFINE3(fanotify_init, unsigned int, flags, unsigned int, event_f_flags,
|
||||||
unsigned int, priority)
|
unsigned int, priority)
|
||||||
|
@ -505,7 +491,16 @@ SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags,
|
||||||
if (mask & ((__u64)0xffffffff << 32))
|
if (mask & ((__u64)0xffffffff << 32))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!fanotify_mark_validate_input(flags, mask))
|
if (flags & ~FAN_ALL_MARK_FLAGS)
|
||||||
|
return -EINVAL;
|
||||||
|
switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE)) {
|
||||||
|
case FAN_MARK_ADD:
|
||||||
|
case FAN_MARK_REMOVE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if (mask & ~(FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
filp = fget_light(fanotify_fd, &fput_needed);
|
filp = fget_light(fanotify_fd, &fput_needed);
|
||||||
|
|
|
@ -47,13 +47,6 @@
|
||||||
FAN_CLOSE |\
|
FAN_CLOSE |\
|
||||||
FAN_OPEN)
|
FAN_OPEN)
|
||||||
|
|
||||||
/*
|
|
||||||
* All legal FAN bits userspace can request (although possibly not all
|
|
||||||
* at the same time.
|
|
||||||
*/
|
|
||||||
#define FAN_ALL_INCOMING_EVENTS (FAN_ALL_EVENTS |\
|
|
||||||
FAN_EVENT_ON_CHILD)
|
|
||||||
|
|
||||||
#define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\
|
#define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\
|
||||||
FAN_Q_OVERFLOW)
|
FAN_Q_OVERFLOW)
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче