Skip to content

Commit 477cf91

Browse files
amir73iljankara
authored andcommitted
fsnotify: use an enum for group priority constants
And use meaningfull names for the constants. Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent cb5d4f4 commit 477cf91

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

fs/notify/fanotify/fanotify_user.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,13 +1516,13 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
15161516
INIT_LIST_HEAD(&group->fanotify_data.access_list);
15171517
switch (class) {
15181518
case FAN_CLASS_NOTIF:
1519-
group->priority = FS_PRIO_0;
1519+
group->priority = FSNOTIFY_PRIO_NORMAL;
15201520
break;
15211521
case FAN_CLASS_CONTENT:
1522-
group->priority = FS_PRIO_1;
1522+
group->priority = FSNOTIFY_PRIO_CONTENT;
15231523
break;
15241524
case FAN_CLASS_PRE_CONTENT:
1525-
group->priority = FS_PRIO_2;
1525+
group->priority = FSNOTIFY_PRIO_PRE_CONTENT;
15261526
break;
15271527
default:
15281528
fd = -EINVAL;
@@ -1774,12 +1774,11 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
17741774
goto fput_and_out;
17751775

17761776
/*
1777-
* group->priority == FS_PRIO_0 == FAN_CLASS_NOTIF. These are not
1778-
* allowed to set permissions events.
1777+
* Permission events require minimum priority FAN_CLASS_CONTENT.
17791778
*/
17801779
ret = -EINVAL;
17811780
if (mask & FANOTIFY_PERM_EVENTS &&
1782-
group->priority == FS_PRIO_0)
1781+
group->priority < FSNOTIFY_PRIO_CONTENT)
17831782
goto fput_and_out;
17841783

17851784
if (mask & FAN_FS_ERROR &&

include/linux/fsnotify_backend.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ struct fsnotify_event {
176176
struct list_head list;
177177
};
178178

179+
/*
180+
* fsnotify group priorities.
181+
* Events are sent in order from highest priority to lowest priority.
182+
*/
183+
enum fsnotify_group_prio {
184+
FSNOTIFY_PRIO_NORMAL = 0, /* normal notifiers, no permissions */
185+
FSNOTIFY_PRIO_CONTENT, /* fanotify permission events */
186+
FSNOTIFY_PRIO_PRE_CONTENT, /* fanotify pre-content events */
187+
__FSNOTIFY_PRIO_NUM
188+
};
189+
179190
/*
180191
* A group is a "thing" that wants to receive notification about filesystem
181192
* events. The mask holds the subset of event types this group cares about.
@@ -201,14 +212,7 @@ struct fsnotify_group {
201212
wait_queue_head_t notification_waitq; /* read() on the notification file blocks on this waitq */
202213
unsigned int q_len; /* events on the queue */
203214
unsigned int max_events; /* maximum events allowed on the list */
204-
/*
205-
* Valid fsnotify group priorities. Events are send in order from highest
206-
* priority to lowest priority. We default to the lowest priority.
207-
*/
208-
#define FS_PRIO_0 0 /* normal notifiers, no permissions */
209-
#define FS_PRIO_1 1 /* fanotify content based access control */
210-
#define FS_PRIO_2 2 /* fanotify pre-content access */
211-
unsigned int priority;
215+
enum fsnotify_group_prio priority; /* priority for sending events */
212216
bool shutdown; /* group is being shut down, don't queue more events */
213217

214218
#define FSNOTIFY_GROUP_USER 0x01 /* user allocated group */

0 commit comments

Comments
 (0)