Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
90586523 EP |
2 | /* |
3 | * Filesystem access notification for Linux | |
4 | * | |
5 | * Copyright (C) 2008 Red Hat, Inc., Eric Paris <eparis@redhat.com> | |
6 | */ | |
7 | ||
8 | #ifndef __LINUX_FSNOTIFY_BACKEND_H | |
9 | #define __LINUX_FSNOTIFY_BACKEND_H | |
10 | ||
11 | #ifdef __KERNEL__ | |
12 | ||
63c882a0 | 13 | #include <linux/idr.h> /* inotify uses this */ |
90586523 EP |
14 | #include <linux/fs.h> /* struct inode */ |
15 | #include <linux/list.h> | |
16 | #include <linux/path.h> /* struct path */ | |
17 | #include <linux/spinlock.h> | |
18 | #include <linux/types.h> | |
60063497 | 19 | #include <linux/atomic.h> |
1cce1eea | 20 | #include <linux/user_namespace.h> |
7761daa6 | 21 | #include <linux/refcount.h> |
734a1a5e | 22 | #include <linux/mempool.h> |
43b245a7 | 23 | #include <linux/sched/mm.h> |
90586523 EP |
24 | |
25 | /* | |
26 | * IN_* from inotfy.h lines up EXACTLY with FS_*, this is so we can easily | |
27 | * convert between them. dnotify only needs conversion at watch creation | |
28 | * so no perf loss there. fanotify isn't defined yet, so it can use the | |
29 | * wholes if it needs more events. | |
30 | */ | |
31 | #define FS_ACCESS 0x00000001 /* File was accessed */ | |
32 | #define FS_MODIFY 0x00000002 /* File was modified */ | |
33 | #define FS_ATTRIB 0x00000004 /* Metadata changed */ | |
9fe0c03f VP |
34 | #define FS_CLOSE_WRITE 0x00000008 /* Writable file was closed */ |
35 | #define FS_CLOSE_NOWRITE 0x00000010 /* Unwritable file closed */ | |
90586523 EP |
36 | #define FS_OPEN 0x00000020 /* File was opened */ |
37 | #define FS_MOVED_FROM 0x00000040 /* File was moved from X */ | |
38 | #define FS_MOVED_TO 0x00000080 /* File was moved to Y */ | |
39 | #define FS_CREATE 0x00000100 /* Subfile was created */ | |
40 | #define FS_DELETE 0x00000200 /* Subfile was deleted */ | |
41 | #define FS_DELETE_SELF 0x00000400 /* Self was deleted */ | |
42 | #define FS_MOVE_SELF 0x00000800 /* Self was moved */ | |
9b076f1c | 43 | #define FS_OPEN_EXEC 0x00001000 /* File was opened for exec */ |
90586523 EP |
44 | |
45 | #define FS_UNMOUNT 0x00002000 /* inode on umount fs */ | |
46 | #define FS_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ | |
9daa8110 GKB |
47 | #define FS_ERROR 0x00008000 /* Filesystem Error (fanotify) */ |
48 | ||
49 | /* | |
50 | * FS_IN_IGNORED overloads FS_ERROR. It is only used internally by inotify | |
51 | * which does not support FS_ERROR. | |
52 | */ | |
90586523 EP |
53 | #define FS_IN_IGNORED 0x00008000 /* last inotify event here */ |
54 | ||
c4ec54b4 EP |
55 | #define FS_OPEN_PERM 0x00010000 /* open event in an permission hook */ |
56 | #define FS_ACCESS_PERM 0x00020000 /* access event in a permissions hook */ | |
66917a31 | 57 | #define FS_OPEN_EXEC_PERM 0x00040000 /* open/exec event in a permission hook */ |
c4ec54b4 | 58 | |
9b93f331 AG |
59 | /* |
60 | * Set on inode mark that cares about things that happen to its children. | |
61 | * Always set for dnotify and inotify. | |
62 | * Set on inode/sb/mount marks that care about parent/name info. | |
63 | */ | |
c28f7e56 EP |
64 | #define FS_EVENT_ON_CHILD 0x08000000 |
65 | ||
e54183fa | 66 | #define FS_RENAME 0x10000000 /* File was renamed */ |
6473ea76 AG |
67 | #define FS_DN_MULTISHOT 0x20000000 /* dnotify multishot */ |
68 | #define FS_ISDIR 0x40000000 /* event occurred against dir */ | |
6473ea76 | 69 | |
e9fd702a EP |
70 | #define FS_MOVE (FS_MOVED_FROM | FS_MOVED_TO) |
71 | ||
e220140f AG |
72 | /* |
73 | * Directory entry modification events - reported only to directory | |
74 | * where entry is modified and not to a watching parent. | |
75 | * The watching parent may get an FS_ATTRIB|FS_EVENT_ON_CHILD event | |
76 | * when a directory entry inside a child subdir changes. | |
77 | */ | |
e54183fa | 78 | #define ALL_FSNOTIFY_DIRENT_EVENTS (FS_CREATE | FS_DELETE | FS_MOVE | FS_RENAME) |
e220140f | 79 | |
66917a31 MB |
80 | #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM | \ |
81 | FS_OPEN_EXEC_PERM) | |
ff8bcbd0 | 82 | |
e220140f | 83 | /* |
9b93f331 AG |
84 | * This is a list of all events that may get sent to a parent that is watching |
85 | * with flag FS_EVENT_ON_CHILD based on fs event on a child of that directory. | |
e220140f AG |
86 | */ |
87 | #define FS_EVENTS_POSS_ON_CHILD (ALL_FSNOTIFY_PERM_EVENTS | \ | |
88 | FS_ACCESS | FS_MODIFY | FS_ATTRIB | \ | |
89 | FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | \ | |
90 | FS_OPEN | FS_OPEN_EXEC) | |
91 | ||
9b93f331 AG |
92 | /* |
93 | * This is a list of all events that may get sent with the parent inode as the | |
94 | * @to_tell argument of fsnotify(). | |
95 | * It may include events that can be sent to an inode/sb/mount mark, but cannot | |
96 | * be sent to a parent watching children. | |
97 | */ | |
98 | #define FS_EVENTS_POSS_TO_PARENT (FS_EVENTS_POSS_ON_CHILD) | |
99 | ||
007d1e83 | 100 | /* Events that can be reported to backends */ |
e220140f AG |
101 | #define ALL_FSNOTIFY_EVENTS (ALL_FSNOTIFY_DIRENT_EVENTS | \ |
102 | FS_EVENTS_POSS_ON_CHILD | \ | |
e54183fa | 103 | FS_DELETE_SELF | FS_MOVE_SELF | \ |
9daa8110 GKB |
104 | FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \ |
105 | FS_ERROR) | |
007d1e83 AG |
106 | |
107 | /* Extra flags that may be reported with event or control handling of events */ | |
38035c04 | 108 | #define ALL_FSNOTIFY_FLAGS (FS_ISDIR | FS_EVENT_ON_CHILD | FS_DN_MULTISHOT) |
20dee624 | 109 | |
007d1e83 AG |
110 | #define ALL_FSNOTIFY_BITS (ALL_FSNOTIFY_EVENTS | ALL_FSNOTIFY_FLAGS) |
111 | ||
90586523 EP |
112 | struct fsnotify_group; |
113 | struct fsnotify_event; | |
e61ce867 | 114 | struct fsnotify_mark; |
e4aff117 | 115 | struct fsnotify_event_private_data; |
7053aee2 | 116 | struct fsnotify_fname; |
abc77577 | 117 | struct fsnotify_iter_info; |
90586523 | 118 | |
d46eb14b SB |
119 | struct mem_cgroup; |
120 | ||
90586523 EP |
121 | /* |
122 | * Each group much define these ops. The fsnotify infrastructure will call | |
123 | * these operations for each relevant group. | |
124 | * | |
125 | * handle_event - main call for a group to handle an fs event | |
b54cecf5 AG |
126 | * @group: group to notify |
127 | * @mask: event type and flags | |
128 | * @data: object that event happened on | |
129 | * @data_type: type of object for fanotify_data_XXX() accessors | |
130 | * @dir: optional directory associated with event - | |
131 | * if @file_name is not NULL, this is the directory that | |
132 | * @file_name is relative to | |
133 | * @file_name: optional file name associated with event | |
134 | * @cookie: inotify rename cookie | |
135 | * @iter_info: array of marks from this group that are interested in the event | |
136 | * | |
b9a1b977 AG |
137 | * handle_inode_event - simple variant of handle_event() for groups that only |
138 | * have inode marks and don't have ignore mask | |
139 | * @mark: mark to notify | |
140 | * @mask: event type and flags | |
141 | * @inode: inode that event happened on | |
142 | * @dir: optional directory associated with event - | |
143 | * if @file_name is not NULL, this is the directory that | |
144 | * @file_name is relative to. | |
24dca905 | 145 | * Either @inode or @dir must be non-NULL. |
b9a1b977 | 146 | * @file_name: optional file name associated with event |
950cc0d2 | 147 | * @cookie: inotify rename cookie |
b9a1b977 | 148 | * |
90586523 | 149 | * free_group_priv - called when a group refcnt hits 0 to clean up the private union |
6960b0d9 | 150 | * freeing_mark - called when a mark is being destroyed for some reason. The group |
b9a1b977 AG |
151 | * MUST be holding a reference on each mark and that reference must be |
152 | * dropped in this function. inotify uses this function to send | |
153 | * userspace messages that marks have been removed. | |
90586523 EP |
154 | */ |
155 | struct fsnotify_ops { | |
b54cecf5 AG |
156 | int (*handle_event)(struct fsnotify_group *group, u32 mask, |
157 | const void *data, int data_type, struct inode *dir, | |
e43e9c33 | 158 | const struct qstr *file_name, u32 cookie, |
9385a84d | 159 | struct fsnotify_iter_info *iter_info); |
b9a1b977 AG |
160 | int (*handle_inode_event)(struct fsnotify_mark *mark, u32 mask, |
161 | struct inode *inode, struct inode *dir, | |
950cc0d2 | 162 | const struct qstr *file_name, u32 cookie); |
90586523 | 163 | void (*free_group_priv)(struct fsnotify_group *group); |
841bdc10 | 164 | void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group); |
330ae77d | 165 | void (*free_event)(struct fsnotify_group *group, struct fsnotify_event *event); |
054c636e JK |
166 | /* called on final put+free to free memory */ |
167 | void (*free_mark)(struct fsnotify_mark *mark); | |
7053aee2 JK |
168 | }; |
169 | ||
170 | /* | |
171 | * all of the information about the original object we want to now send to | |
172 | * a group. If you want to carry more info from the accessing task to the | |
173 | * listener this structure is where you need to be adding fields. | |
174 | */ | |
175 | struct fsnotify_event { | |
176 | struct list_head list; | |
90586523 EP |
177 | }; |
178 | ||
477cf917 AG |
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 | ||
90586523 EP |
190 | /* |
191 | * A group is a "thing" that wants to receive notification about filesystem | |
192 | * events. The mask holds the subset of event types this group cares about. | |
193 | * refcnt on a group is up to the implementor and at any moment if it goes 0 | |
194 | * everything will be cleaned up. | |
195 | */ | |
196 | struct fsnotify_group { | |
d46eb14b SB |
197 | const struct fsnotify_ops *ops; /* how this group handles things */ |
198 | ||
90586523 EP |
199 | /* |
200 | * How the refcnt is used is up to each group. When the refcnt hits 0 | |
201 | * fsnotify will clean up all of the resources associated with this group. | |
202 | * As an example, the dnotify group will always have a refcnt=1 and that | |
203 | * will never change. Inotify, on the other hand, has a group per | |
204 | * inotify_init() and the refcnt will hit 0 only when that fd has been | |
205 | * closed. | |
206 | */ | |
7761daa6 | 207 | refcount_t refcnt; /* things with interest in this group */ |
90586523 | 208 | |
a2d8bc6c | 209 | /* needed to send notification to userspace */ |
c21dbe20 | 210 | spinlock_t notification_lock; /* protect the notification_list */ |
a2d8bc6c EP |
211 | struct list_head notification_list; /* list of event_holder this group needs to send to userspace */ |
212 | wait_queue_head_t notification_waitq; /* read() on the notification file blocks on this waitq */ | |
213 | unsigned int q_len; /* events on the queue */ | |
214 | unsigned int max_events; /* maximum events allowed on the list */ | |
477cf917 | 215 | enum fsnotify_group_prio priority; /* priority for sending events */ |
12703dbf | 216 | bool shutdown; /* group is being shut down, don't queue more events */ |
a2d8bc6c | 217 | |
867a448d | 218 | #define FSNOTIFY_GROUP_USER 0x01 /* user allocated group */ |
f3010343 | 219 | #define FSNOTIFY_GROUP_DUPS 0x02 /* allow multiple marks per object */ |
43b245a7 | 220 | #define FSNOTIFY_GROUP_NOFS 0x04 /* group lock is not direct reclaim safe */ |
867a448d | 221 | int flags; |
43b245a7 | 222 | unsigned int owner_flags; /* stored flags of mark_mutex owner */ |
867a448d | 223 | |
e61ce867 | 224 | /* stores all fastpath marks assoc with this group so they can be cleaned on unregister */ |
986ab098 | 225 | struct mutex mark_mutex; /* protect marks_list */ |
d46eb14b SB |
226 | atomic_t user_waits; /* Number of tasks waiting for user |
227 | * response */ | |
e61ce867 | 228 | struct list_head marks_list; /* all inode marks for this group */ |
3be25f49 | 229 | |
7053aee2 JK |
230 | struct fasync_struct *fsn_fa; /* async notification */ |
231 | ||
ff57cd58 | 232 | struct fsnotify_event *overflow_event; /* Event we queue when the |
7053aee2 JK |
233 | * notification list is too |
234 | * full */ | |
d46eb14b SB |
235 | |
236 | struct mem_cgroup *memcg; /* memcg to charge allocations */ | |
0a6b6bd5 | 237 | |
90586523 EP |
238 | /* groups can define private fields here or use the void *private */ |
239 | union { | |
240 | void *private; | |
63c882a0 EP |
241 | #ifdef CONFIG_INOTIFY_USER |
242 | struct inotify_group_private_data { | |
243 | spinlock_t idr_lock; | |
244 | struct idr idr; | |
1cce1eea | 245 | struct ucounts *ucounts; |
63c882a0 | 246 | } inotify_data; |
9e66e423 | 247 | #endif |
80af2588 | 248 | #ifdef CONFIG_FANOTIFY |
9e66e423 | 249 | struct fanotify_group_private_data { |
94e00d28 AG |
250 | /* Hash table of events for merge */ |
251 | struct hlist_head *merge_hash; | |
9e66e423 | 252 | /* allows a group to block waiting for a userspace response */ |
9e66e423 EP |
253 | struct list_head access_list; |
254 | wait_queue_head_t access_waitq; | |
96a71f21 AG |
255 | int flags; /* flags from fanotify_init() */ |
256 | int f_flags; /* event_f_flags from fanotify_init() */ | |
5b8fea65 | 257 | struct ucounts *ucounts; |
734a1a5e | 258 | mempool_t error_events_pool; |
9e66e423 | 259 | } fanotify_data; |
80af2588 | 260 | #endif /* CONFIG_FANOTIFY */ |
90586523 EP |
261 | }; |
262 | }; | |
263 | ||
43b245a7 AG |
264 | /* |
265 | * These helpers are used to prevent deadlock when reclaiming inodes with | |
266 | * evictable marks of the same group that is allocating a new mark. | |
267 | */ | |
268 | static inline void fsnotify_group_lock(struct fsnotify_group *group) | |
269 | { | |
270 | mutex_lock(&group->mark_mutex); | |
271 | if (group->flags & FSNOTIFY_GROUP_NOFS) | |
272 | group->owner_flags = memalloc_nofs_save(); | |
273 | } | |
274 | ||
275 | static inline void fsnotify_group_unlock(struct fsnotify_group *group) | |
276 | { | |
277 | if (group->flags & FSNOTIFY_GROUP_NOFS) | |
278 | memalloc_nofs_restore(group->owner_flags); | |
279 | mutex_unlock(&group->mark_mutex); | |
280 | } | |
281 | ||
282 | static inline void fsnotify_group_assert_locked(struct fsnotify_group *group) | |
283 | { | |
284 | WARN_ON_ONCE(!mutex_is_locked(&group->mark_mutex)); | |
285 | if (group->flags & FSNOTIFY_GROUP_NOFS) | |
286 | WARN_ON_ONCE(!(current->flags & PF_MEMALLOC_NOFS)); | |
287 | } | |
288 | ||
aa93bdc5 AG |
289 | /* When calling fsnotify tell it if the data is a path or inode */ |
290 | enum fsnotify_data_type { | |
291 | FSNOTIFY_EVENT_NONE, | |
292 | FSNOTIFY_EVENT_PATH, | |
293 | FSNOTIFY_EVENT_INODE, | |
fd5a3ff4 | 294 | FSNOTIFY_EVENT_DENTRY, |
9daa8110 GKB |
295 | FSNOTIFY_EVENT_ERROR, |
296 | }; | |
297 | ||
298 | struct fs_error_report { | |
299 | int error; | |
300 | struct inode *inode; | |
301 | struct super_block *sb; | |
aa93bdc5 AG |
302 | }; |
303 | ||
cbcf47ad | 304 | static inline struct inode *fsnotify_data_inode(const void *data, int data_type) |
aa93bdc5 AG |
305 | { |
306 | switch (data_type) { | |
307 | case FSNOTIFY_EVENT_INODE: | |
cbcf47ad | 308 | return (struct inode *)data; |
fd5a3ff4 AG |
309 | case FSNOTIFY_EVENT_DENTRY: |
310 | return d_inode(data); | |
aa93bdc5 AG |
311 | case FSNOTIFY_EVENT_PATH: |
312 | return d_inode(((const struct path *)data)->dentry); | |
9daa8110 GKB |
313 | case FSNOTIFY_EVENT_ERROR: |
314 | return ((struct fs_error_report *)data)->inode; | |
aa93bdc5 AG |
315 | default: |
316 | return NULL; | |
317 | } | |
fd5a3ff4 AG |
318 | } |
319 | ||
320 | static inline struct dentry *fsnotify_data_dentry(const void *data, int data_type) | |
321 | { | |
322 | switch (data_type) { | |
323 | case FSNOTIFY_EVENT_DENTRY: | |
324 | /* Non const is needed for dget() */ | |
325 | return (struct dentry *)data; | |
326 | case FSNOTIFY_EVENT_PATH: | |
327 | return ((const struct path *)data)->dentry; | |
328 | default: | |
329 | return NULL; | |
330 | } | |
aa93bdc5 AG |
331 | } |
332 | ||
333 | static inline const struct path *fsnotify_data_path(const void *data, | |
334 | int data_type) | |
335 | { | |
336 | switch (data_type) { | |
337 | case FSNOTIFY_EVENT_PATH: | |
338 | return data; | |
339 | default: | |
340 | return NULL; | |
341 | } | |
342 | } | |
90586523 | 343 | |
29335033 GKB |
344 | static inline struct super_block *fsnotify_data_sb(const void *data, |
345 | int data_type) | |
346 | { | |
347 | switch (data_type) { | |
348 | case FSNOTIFY_EVENT_INODE: | |
349 | return ((struct inode *)data)->i_sb; | |
350 | case FSNOTIFY_EVENT_DENTRY: | |
351 | return ((struct dentry *)data)->d_sb; | |
352 | case FSNOTIFY_EVENT_PATH: | |
353 | return ((const struct path *)data)->dentry->d_sb; | |
9daa8110 GKB |
354 | case FSNOTIFY_EVENT_ERROR: |
355 | return ((struct fs_error_report *) data)->sb; | |
356 | default: | |
357 | return NULL; | |
358 | } | |
359 | } | |
360 | ||
361 | static inline struct fs_error_report *fsnotify_data_error_report( | |
362 | const void *data, | |
363 | int data_type) | |
364 | { | |
365 | switch (data_type) { | |
366 | case FSNOTIFY_EVENT_ERROR: | |
367 | return (struct fs_error_report *) data; | |
29335033 GKB |
368 | default: |
369 | return NULL; | |
370 | } | |
371 | } | |
372 | ||
1c9007d6 AG |
373 | /* |
374 | * Index to merged marks iterator array that correlates to a type of watch. | |
375 | * The type of watched object can be deduced from the iterator type, but not | |
376 | * the other way around, because an event can match different watched objects | |
377 | * of the same object type. | |
378 | * For example, both parent and child are watching an object of type inode. | |
379 | */ | |
380 | enum fsnotify_iter_type { | |
381 | FSNOTIFY_ITER_TYPE_INODE, | |
382 | FSNOTIFY_ITER_TYPE_VFSMOUNT, | |
383 | FSNOTIFY_ITER_TYPE_SB, | |
384 | FSNOTIFY_ITER_TYPE_PARENT, | |
e54183fa | 385 | FSNOTIFY_ITER_TYPE_INODE2, |
1c9007d6 AG |
386 | FSNOTIFY_ITER_TYPE_COUNT |
387 | }; | |
388 | ||
389 | /* The type of object that a mark is attached to */ | |
d6f7b98b | 390 | enum fsnotify_obj_type { |
ad69cd99 | 391 | FSNOTIFY_OBJ_TYPE_ANY = -1, |
d6f7b98b AG |
392 | FSNOTIFY_OBJ_TYPE_INODE, |
393 | FSNOTIFY_OBJ_TYPE_VFSMOUNT, | |
1e6cb723 | 394 | FSNOTIFY_OBJ_TYPE_SB, |
d6f7b98b AG |
395 | FSNOTIFY_OBJ_TYPE_COUNT, |
396 | FSNOTIFY_OBJ_TYPE_DETACHED = FSNOTIFY_OBJ_TYPE_COUNT | |
397 | }; | |
398 | ||
ad69cd99 | 399 | static inline bool fsnotify_valid_obj_type(unsigned int obj_type) |
b812a9f5 | 400 | { |
ad69cd99 | 401 | return (obj_type < FSNOTIFY_OBJ_TYPE_COUNT); |
b812a9f5 AG |
402 | } |
403 | ||
5b0457ad | 404 | struct fsnotify_iter_info { |
1c9007d6 | 405 | struct fsnotify_mark *marks[FSNOTIFY_ITER_TYPE_COUNT]; |
14362a25 | 406 | struct fsnotify_group *current_group; |
5b0457ad AG |
407 | unsigned int report_mask; |
408 | int srcu_idx; | |
409 | }; | |
410 | ||
47d9c7cc | 411 | static inline bool fsnotify_iter_should_report_type( |
1c9007d6 | 412 | struct fsnotify_iter_info *iter_info, int iter_type) |
47d9c7cc | 413 | { |
1c9007d6 | 414 | return (iter_info->report_mask & (1U << iter_type)); |
47d9c7cc AG |
415 | } |
416 | ||
417 | static inline void fsnotify_iter_set_report_type( | |
1c9007d6 | 418 | struct fsnotify_iter_info *iter_info, int iter_type) |
47d9c7cc | 419 | { |
1c9007d6 | 420 | iter_info->report_mask |= (1U << iter_type); |
47d9c7cc AG |
421 | } |
422 | ||
14362a25 AG |
423 | static inline struct fsnotify_mark *fsnotify_iter_mark( |
424 | struct fsnotify_iter_info *iter_info, int iter_type) | |
47d9c7cc | 425 | { |
14362a25 AG |
426 | if (fsnotify_iter_should_report_type(iter_info, iter_type)) |
427 | return iter_info->marks[iter_type]; | |
428 | return NULL; | |
429 | } | |
430 | ||
431 | static inline int fsnotify_iter_step(struct fsnotify_iter_info *iter, int type, | |
432 | struct fsnotify_mark **markp) | |
433 | { | |
434 | while (type < FSNOTIFY_ITER_TYPE_COUNT) { | |
435 | *markp = fsnotify_iter_mark(iter, type); | |
436 | if (*markp) | |
437 | break; | |
438 | type++; | |
439 | } | |
440 | return type; | |
47d9c7cc AG |
441 | } |
442 | ||
5b0457ad AG |
443 | #define FSNOTIFY_ITER_FUNCS(name, NAME) \ |
444 | static inline struct fsnotify_mark *fsnotify_iter_##name##_mark( \ | |
445 | struct fsnotify_iter_info *iter_info) \ | |
446 | { \ | |
14362a25 | 447 | return fsnotify_iter_mark(iter_info, FSNOTIFY_ITER_TYPE_##NAME); \ |
5b0457ad AG |
448 | } |
449 | ||
450 | FSNOTIFY_ITER_FUNCS(inode, INODE) | |
fecc4559 | 451 | FSNOTIFY_ITER_FUNCS(parent, PARENT) |
5b0457ad | 452 | FSNOTIFY_ITER_FUNCS(vfsmount, VFSMOUNT) |
1e6cb723 | 453 | FSNOTIFY_ITER_FUNCS(sb, SB) |
5b0457ad | 454 | |
1c9007d6 AG |
455 | #define fsnotify_foreach_iter_type(type) \ |
456 | for (type = 0; type < FSNOTIFY_ITER_TYPE_COUNT; type++) | |
14362a25 AG |
457 | #define fsnotify_foreach_iter_mark_type(iter, mark, type) \ |
458 | for (type = 0; \ | |
459 | type = fsnotify_iter_step(iter, type, &mark), \ | |
460 | type < FSNOTIFY_ITER_TYPE_COUNT; \ | |
461 | type++) | |
47d9c7cc | 462 | |
9dd813c1 | 463 | /* |
1e6cb723 AG |
464 | * Inode/vfsmount/sb point to this structure which tracks all marks attached to |
465 | * the inode/vfsmount/sb. The reference to inode/vfsmount/sb is held by this | |
08991e83 JK |
466 | * structure. We destroy this structure when there are no more marks attached |
467 | * to it. The structure is protected by fsnotify_mark_srcu. | |
9dd813c1 JK |
468 | */ |
469 | struct fsnotify_mark_connector { | |
04662cab | 470 | spinlock_t lock; |
a5e57b4d AG |
471 | unsigned char type; /* Type of object [lock] */ |
472 | unsigned char prio; /* Highest priority group */ | |
c9d4603b | 473 | #define FSNOTIFY_CONN_FLAG_IS_WATCHED 0x01 |
c3638b5b | 474 | #define FSNOTIFY_CONN_FLAG_HAS_IREF 0x02 |
c285a2f0 | 475 | unsigned short flags; /* flags [lock] */ |
36f10f55 AG |
476 | union { |
477 | /* Object pointer [lock] */ | |
687c217c | 478 | void *obj; |
08991e83 JK |
479 | /* Used listing heads to free after srcu period expires */ |
480 | struct fsnotify_mark_connector *destroy_next; | |
481 | }; | |
d90a10e2 | 482 | struct hlist_head list; |
9dd813c1 JK |
483 | }; |
484 | ||
07a3b8d0 AG |
485 | /* |
486 | * Container for per-sb fsnotify state (sb marks and more). | |
487 | * Attached lazily on first marked object on the sb and freed when killing sb. | |
488 | */ | |
489 | struct fsnotify_sb_info { | |
490 | struct fsnotify_mark_connector __rcu *sb_marks; | |
cb5d4f48 AG |
491 | /* |
492 | * Number of inode/mount/sb objects that are being watched in this sb. | |
493 | * Note that inodes objects are currently double-accounted. | |
a5e57b4d AG |
494 | * |
495 | * The value in watched_objects[prio] is the number of objects that are | |
496 | * watched by groups of priority >= prio, so watched_objects[0] is the | |
497 | * total number of watched objects in this sb. | |
cb5d4f48 | 498 | */ |
a5e57b4d | 499 | atomic_long_t watched_objects[__FSNOTIFY_PRIO_NUM]; |
07a3b8d0 AG |
500 | }; |
501 | ||
502 | static inline struct fsnotify_sb_info *fsnotify_sb_info(struct super_block *sb) | |
503 | { | |
504 | #ifdef CONFIG_FSNOTIFY | |
505 | return READ_ONCE(sb->s_fsnotify_info); | |
506 | #else | |
507 | return NULL; | |
508 | #endif | |
509 | } | |
510 | ||
d2f277e2 AG |
511 | static inline atomic_long_t *fsnotify_sb_watched_objects(struct super_block *sb) |
512 | { | |
a5e57b4d | 513 | return &fsnotify_sb_info(sb)->watched_objects[0]; |
d2f277e2 AG |
514 | } |
515 | ||
3be25f49 | 516 | /* |
1e39fc01 | 517 | * A mark is simply an object attached to an in core inode which allows an |
3be25f49 EP |
518 | * fsnotify listener to indicate they are either no longer interested in events |
519 | * of a type matching mask or only interested in those events. | |
520 | * | |
1e39fc01 JK |
521 | * These are flushed when an inode is evicted from core and may be flushed |
522 | * when the inode is modified (as seen by fsnotify_access). Some fsnotify | |
523 | * users (such as dnotify) will flush these when the open fd is closed and not | |
524 | * at inode eviction or modification. | |
525 | * | |
526 | * Text in brackets is showing the lock(s) protecting modifications of a | |
527 | * particular entry. obj_lock means either inode->i_lock or | |
528 | * mnt->mnt_root->d_lock depending on the mark type. | |
3be25f49 | 529 | */ |
e61ce867 | 530 | struct fsnotify_mark { |
1e39fc01 JK |
531 | /* Mask this mark is for [mark->lock, group->mark_mutex] */ |
532 | __u32 mask; | |
533 | /* We hold one for presence in g_list. Also one ref for each 'thing' | |
3be25f49 | 534 | * in kernel that found and may be using this mark. */ |
ab97f873 | 535 | refcount_t refcnt; |
1e39fc01 JK |
536 | /* Group this mark is for. Set on mark creation, stable until last ref |
537 | * is dropped */ | |
538 | struct fsnotify_group *group; | |
8e984f86 | 539 | /* List of marks by group->marks_list. Also reused for queueing |
1e39fc01 JK |
540 | * mark into destroy_list when it's waiting for the end of SRCU period |
541 | * before it can be freed. [group->mark_mutex] */ | |
13d34ac6 | 542 | struct list_head g_list; |
1e39fc01 JK |
543 | /* Protects inode / mnt pointers, flags, masks */ |
544 | spinlock_t lock; | |
6b3f05d2 | 545 | /* List of marks for inode / vfsmount [connector->lock, mark ref] */ |
1e39fc01 | 546 | struct hlist_node obj_list; |
6b3f05d2 | 547 | /* Head of list of marks for an object [mark ref] */ |
86ffe245 | 548 | struct fsnotify_mark_connector *connector; |
31a371e4 AG |
549 | /* Events types and flags to ignore [mark->lock, group->mark_mutex] */ |
550 | __u32 ignore_mask; | |
38035c04 AG |
551 | /* General fsnotify mark flags */ |
552 | #define FSNOTIFY_MARK_FLAG_ALIVE 0x0001 | |
553 | #define FSNOTIFY_MARK_FLAG_ATTACHED 0x0002 | |
554 | /* inotify mark flags */ | |
555 | #define FSNOTIFY_MARK_FLAG_EXCL_UNLINK 0x0010 | |
556 | #define FSNOTIFY_MARK_FLAG_IN_ONESHOT 0x0020 | |
557 | /* fanotify mark flags */ | |
558 | #define FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY 0x0100 | |
c3638b5b | 559 | #define FSNOTIFY_MARK_FLAG_NO_IREF 0x0200 |
31a371e4 | 560 | #define FSNOTIFY_MARK_FLAG_HAS_IGNORE_FLAGS 0x0400 |
7232522e | 561 | #define FSNOTIFY_MARK_FLAG_HAS_FSID 0x0800 |
30ad1938 | 562 | #define FSNOTIFY_MARK_FLAG_WEAK_FSID 0x1000 |
1e39fc01 | 563 | unsigned int flags; /* flags [mark->lock] */ |
3be25f49 EP |
564 | }; |
565 | ||
90586523 EP |
566 | #ifdef CONFIG_FSNOTIFY |
567 | ||
568 | /* called from the vfs helpers */ | |
569 | ||
570 | /* main fsnotify call to send events */ | |
40a100d3 AG |
571 | extern int fsnotify(__u32 mask, const void *data, int data_type, |
572 | struct inode *dir, const struct qstr *name, | |
573 | struct inode *inode, u32 cookie); | |
71d73410 | 574 | extern int __fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data, |
017de65f | 575 | int data_type); |
3be25f49 | 576 | extern void __fsnotify_inode_delete(struct inode *inode); |
ca9c726e | 577 | extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); |
1e6cb723 | 578 | extern void fsnotify_sb_delete(struct super_block *sb); |
795bb82d | 579 | extern void fsnotify_sb_free(struct super_block *sb); |
47882c6f | 580 | extern u32 fsnotify_get_cookie(void); |
90586523 | 581 | |
9b93f331 AG |
582 | static inline __u32 fsnotify_parent_needed_mask(__u32 mask) |
583 | { | |
584 | /* FS_EVENT_ON_CHILD is set on marks that want parent/name info */ | |
585 | if (!(mask & FS_EVENT_ON_CHILD)) | |
586 | return 0; | |
587 | /* | |
588 | * This object might be watched by a mark that cares about parent/name | |
589 | * info, does it care about the specific set of events that can be | |
590 | * reported with parent/name info? | |
591 | */ | |
592 | return mask & FS_EVENTS_POSS_TO_PARENT; | |
593 | } | |
594 | ||
c28f7e56 EP |
595 | static inline int fsnotify_inode_watches_children(struct inode *inode) |
596 | { | |
172e422f AG |
597 | __u32 parent_mask = READ_ONCE(inode->i_fsnotify_mask); |
598 | ||
c28f7e56 | 599 | /* FS_EVENT_ON_CHILD is set if the inode may care */ |
172e422f | 600 | if (!(parent_mask & FS_EVENT_ON_CHILD)) |
c28f7e56 EP |
601 | return 0; |
602 | /* this inode might care about child events, does it care about the | |
603 | * specific set of events that can happen on a child? */ | |
172e422f | 604 | return parent_mask & FS_EVENTS_POSS_ON_CHILD; |
c28f7e56 EP |
605 | } |
606 | ||
607 | /* | |
608 | * Update the dentry with a flag indicating the interest of its parent to receive | |
609 | * filesystem events when those events happens to this dentry->d_inode. | |
610 | */ | |
affda484 | 611 | static inline void fsnotify_update_flags(struct dentry *dentry) |
c28f7e56 | 612 | { |
c28f7e56 EP |
613 | assert_spin_locked(&dentry->d_lock); |
614 | ||
b5c84bf6 NP |
615 | /* |
616 | * Serialisation of setting PARENT_WATCHED on the dentries is provided | |
617 | * by d_lock. If inotify_inode_watched changes after we have taken | |
172e422f | 618 | * d_lock, the following fsnotify_set_children_dentry_flags call will |
b5c84bf6 NP |
619 | * find our entry, so it will spin until we complete here, and update |
620 | * us with the new state. | |
621 | */ | |
affda484 | 622 | if (fsnotify_inode_watches_children(dentry->d_parent->d_inode)) |
c28f7e56 EP |
623 | dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED; |
624 | else | |
625 | dentry->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED; | |
626 | } | |
627 | ||
90586523 EP |
628 | /* called from fsnotify listeners, such as fanotify or dnotify */ |
629 | ||
98612952 | 630 | /* create a new group */ |
867a448d AG |
631 | extern struct fsnotify_group *fsnotify_alloc_group( |
632 | const struct fsnotify_ops *ops, | |
633 | int flags); | |
98612952 LS |
634 | /* get reference to a group */ |
635 | extern void fsnotify_get_group(struct fsnotify_group *group); | |
ffab8340 | 636 | /* drop reference on a group from fsnotify_alloc_group */ |
90586523 | 637 | extern void fsnotify_put_group(struct fsnotify_group *group); |
12703dbf JK |
638 | /* group destruction begins, stop queuing new events */ |
639 | extern void fsnotify_group_stop_queueing(struct fsnotify_group *group); | |
d8153d4d LS |
640 | /* destroy group */ |
641 | extern void fsnotify_destroy_group(struct fsnotify_group *group); | |
0a6b6bd5 EP |
642 | /* fasync handler function */ |
643 | extern int fsnotify_fasync(int fd, struct file *file, int on); | |
7053aee2 JK |
644 | /* Free event from memory */ |
645 | extern void fsnotify_destroy_event(struct fsnotify_group *group, | |
646 | struct fsnotify_event *event); | |
a2d8bc6c | 647 | /* attach the event to the group notification queue */ |
1ad03c3a GKB |
648 | extern int fsnotify_insert_event(struct fsnotify_group *group, |
649 | struct fsnotify_event *event, | |
650 | int (*merge)(struct fsnotify_group *, | |
651 | struct fsnotify_event *), | |
652 | void (*insert)(struct fsnotify_group *, | |
653 | struct fsnotify_event *)); | |
654 | ||
655 | static inline int fsnotify_add_event(struct fsnotify_group *group, | |
656 | struct fsnotify_event *event, | |
657 | int (*merge)(struct fsnotify_group *, | |
658 | struct fsnotify_event *)) | |
659 | { | |
660 | return fsnotify_insert_event(group, event, merge, NULL); | |
661 | } | |
662 | ||
7b1f6417 JK |
663 | /* Queue overflow event to a notification group */ |
664 | static inline void fsnotify_queue_overflow(struct fsnotify_group *group) | |
665 | { | |
1ad03c3a | 666 | fsnotify_add_event(group, group->overflow_event, NULL); |
7b1f6417 JK |
667 | } |
668 | ||
808967a0 GKB |
669 | static inline bool fsnotify_is_overflow_event(u32 mask) |
670 | { | |
671 | return mask & FS_Q_OVERFLOW; | |
672 | } | |
673 | ||
6f73171e AG |
674 | static inline bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group) |
675 | { | |
676 | assert_spin_locked(&group->notification_lock); | |
677 | ||
678 | return list_empty(&group->notification_list); | |
679 | } | |
680 | ||
a2d8bc6c EP |
681 | extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group); |
682 | /* return, but do not dequeue the first event on the notification queue */ | |
8ba8fa91 | 683 | extern struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group); |
e4aff117 | 684 | /* return AND dequeue the first event on the notification queue */ |
8ba8fa91 | 685 | extern struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group); |
f7db89ac JK |
686 | /* Remove event queued in the notification list */ |
687 | extern void fsnotify_remove_queued_event(struct fsnotify_group *group, | |
688 | struct fsnotify_event *event); | |
a2d8bc6c | 689 | |
3be25f49 EP |
690 | /* functions used to manipulate the marks attached to inodes */ |
691 | ||
31a371e4 AG |
692 | /* |
693 | * Canonical "ignore mask" including event flags. | |
694 | * | |
695 | * Note the subtle semantic difference from the legacy ->ignored_mask. | |
696 | * ->ignored_mask traditionally only meant which events should be ignored, | |
697 | * while ->ignore_mask also includes flags regarding the type of objects on | |
698 | * which events should be ignored. | |
699 | */ | |
700 | static inline __u32 fsnotify_ignore_mask(struct fsnotify_mark *mark) | |
701 | { | |
702 | __u32 ignore_mask = mark->ignore_mask; | |
703 | ||
704 | /* The event flags in ignore mask take effect */ | |
705 | if (mark->flags & FSNOTIFY_MARK_FLAG_HAS_IGNORE_FLAGS) | |
706 | return ignore_mask; | |
707 | ||
708 | /* | |
709 | * Legacy behavior: | |
710 | * - Always ignore events on dir | |
711 | * - Ignore events on child if parent is watching children | |
712 | */ | |
713 | ignore_mask |= FS_ISDIR; | |
714 | ignore_mask &= ~FS_EVENT_ON_CHILD; | |
715 | ignore_mask |= mark->mask & FS_EVENT_ON_CHILD; | |
716 | ||
717 | return ignore_mask; | |
718 | } | |
719 | ||
720 | /* Legacy ignored_mask - only event types to ignore */ | |
721 | static inline __u32 fsnotify_ignored_events(struct fsnotify_mark *mark) | |
722 | { | |
723 | return mark->ignore_mask & ALL_FSNOTIFY_EVENTS; | |
724 | } | |
725 | ||
726 | /* | |
727 | * Check if mask (or ignore mask) should be applied depending if victim is a | |
728 | * directory and whether it is reported to a watching parent. | |
729 | */ | |
730 | static inline bool fsnotify_mask_applicable(__u32 mask, bool is_dir, | |
731 | int iter_type) | |
732 | { | |
733 | /* Should mask be applied to a directory? */ | |
734 | if (is_dir && !(mask & FS_ISDIR)) | |
735 | return false; | |
736 | ||
737 | /* Should mask be applied to a child? */ | |
738 | if (iter_type == FSNOTIFY_ITER_TYPE_PARENT && | |
739 | !(mask & FS_EVENT_ON_CHILD)) | |
740 | return false; | |
741 | ||
742 | return true; | |
743 | } | |
744 | ||
745 | /* | |
746 | * Effective ignore mask taking into account if event victim is a | |
747 | * directory and whether it is reported to a watching parent. | |
748 | */ | |
749 | static inline __u32 fsnotify_effective_ignore_mask(struct fsnotify_mark *mark, | |
750 | bool is_dir, int iter_type) | |
751 | { | |
752 | __u32 ignore_mask = fsnotify_ignored_events(mark); | |
753 | ||
754 | if (!ignore_mask) | |
755 | return 0; | |
756 | ||
757 | /* For non-dir and non-child, no need to consult the event flags */ | |
758 | if (!is_dir && iter_type != FSNOTIFY_ITER_TYPE_PARENT) | |
759 | return ignore_mask; | |
760 | ||
761 | ignore_mask = fsnotify_ignore_mask(mark); | |
762 | if (!fsnotify_mask_applicable(ignore_mask, is_dir, iter_type)) | |
763 | return 0; | |
764 | ||
765 | return ignore_mask & ALL_FSNOTIFY_EVENTS; | |
766 | } | |
767 | ||
768 | /* Get mask for calculating object interest taking ignore mask into account */ | |
4f0b903d AG |
769 | static inline __u32 fsnotify_calc_mask(struct fsnotify_mark *mark) |
770 | { | |
771 | __u32 mask = mark->mask; | |
772 | ||
31a371e4 | 773 | if (!fsnotify_ignored_events(mark)) |
4f0b903d AG |
774 | return mask; |
775 | ||
31a371e4 | 776 | /* Interest in FS_MODIFY may be needed for clearing ignore mask */ |
04e317ba AG |
777 | if (!(mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)) |
778 | mask |= FS_MODIFY; | |
779 | ||
4f0b903d AG |
780 | /* |
781 | * If mark is interested in ignoring events on children, the object must | |
782 | * show interest in those events for fsnotify_parent() to notice it. | |
783 | */ | |
31a371e4 | 784 | return mask | mark->ignore_mask; |
4f0b903d AG |
785 | } |
786 | ||
3ac70bfc AG |
787 | /* Get mask of events for a list of marks */ |
788 | extern __u32 fsnotify_conn_mask(struct fsnotify_mark_connector *conn); | |
a242677b JK |
789 | /* Calculate mask of events for a list of marks */ |
790 | extern void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn); | |
7b129323 | 791 | extern void fsnotify_init_mark(struct fsnotify_mark *mark, |
054c636e | 792 | struct fsnotify_group *group); |
b1362edf | 793 | /* Find mark belonging to given group in the list of marks */ |
687c217c AG |
794 | struct fsnotify_mark *fsnotify_find_mark(void *obj, unsigned int obj_type, |
795 | struct fsnotify_group *group); | |
b812a9f5 | 796 | /* attach the mark to the object */ |
687c217c AG |
797 | int fsnotify_add_mark(struct fsnotify_mark *mark, void *obj, |
798 | unsigned int obj_type, int add_flags); | |
799 | int fsnotify_add_mark_locked(struct fsnotify_mark *mark, void *obj, | |
800 | unsigned int obj_type, int add_flags); | |
77115225 | 801 | |
b249f5be AG |
802 | /* attach the mark to the inode */ |
803 | static inline int fsnotify_add_inode_mark(struct fsnotify_mark *mark, | |
804 | struct inode *inode, | |
f3010343 | 805 | int add_flags) |
b249f5be | 806 | { |
687c217c AG |
807 | return fsnotify_add_mark(mark, inode, FSNOTIFY_OBJ_TYPE_INODE, |
808 | add_flags); | |
b249f5be AG |
809 | } |
810 | static inline int fsnotify_add_inode_mark_locked(struct fsnotify_mark *mark, | |
811 | struct inode *inode, | |
f3010343 | 812 | int add_flags) |
b249f5be | 813 | { |
687c217c AG |
814 | return fsnotify_add_mark_locked(mark, inode, FSNOTIFY_OBJ_TYPE_INODE, |
815 | add_flags); | |
b249f5be | 816 | } |
77115225 | 817 | |
230d97d3 AG |
818 | static inline struct fsnotify_mark *fsnotify_find_inode_mark( |
819 | struct inode *inode, | |
820 | struct fsnotify_group *group) | |
821 | { | |
687c217c | 822 | return fsnotify_find_mark(inode, FSNOTIFY_OBJ_TYPE_INODE, group); |
230d97d3 AG |
823 | } |
824 | ||
e2a29943 LS |
825 | /* given a group and a mark, flag mark to be freed when all references are dropped */ |
826 | extern void fsnotify_destroy_mark(struct fsnotify_mark *mark, | |
827 | struct fsnotify_group *group); | |
4712e722 JK |
828 | /* detach mark from inode / mount list, group list, drop inode reference */ |
829 | extern void fsnotify_detach_mark(struct fsnotify_mark *mark); | |
830 | /* free mark */ | |
831 | extern void fsnotify_free_mark(struct fsnotify_mark *mark); | |
b72679ee TM |
832 | /* Wait until all marks queued for destruction are destroyed */ |
833 | extern void fsnotify_wait_marks_destroyed(void); | |
ad69cd99 AG |
834 | /* Clear all of the marks of a group attached to a given object type */ |
835 | extern void fsnotify_clear_marks_by_group(struct fsnotify_group *group, | |
836 | unsigned int obj_type); | |
416bcdbc JK |
837 | /* run all the marks in a group, and clear all of the vfsmount marks */ |
838 | static inline void fsnotify_clear_vfsmount_marks_by_group(struct fsnotify_group *group) | |
839 | { | |
ad69cd99 | 840 | fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_VFSMOUNT); |
416bcdbc JK |
841 | } |
842 | /* run all the marks in a group, and clear all of the inode marks */ | |
843 | static inline void fsnotify_clear_inode_marks_by_group(struct fsnotify_group *group) | |
844 | { | |
ad69cd99 | 845 | fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_INODE); |
416bcdbc | 846 | } |
1e6cb723 AG |
847 | /* run all the marks in a group, and clear all of the sn marks */ |
848 | static inline void fsnotify_clear_sb_marks_by_group(struct fsnotify_group *group) | |
849 | { | |
ad69cd99 | 850 | fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_SB); |
1e6cb723 | 851 | } |
841bdc10 EP |
852 | extern void fsnotify_get_mark(struct fsnotify_mark *mark); |
853 | extern void fsnotify_put_mark(struct fsnotify_mark *mark); | |
abc77577 JK |
854 | extern void fsnotify_finish_user_wait(struct fsnotify_iter_info *iter_info); |
855 | extern bool fsnotify_prepare_user_wait(struct fsnotify_iter_info *iter_info); | |
3be25f49 | 856 | |
8988f11a | 857 | static inline void fsnotify_init_event(struct fsnotify_event *event) |
a0a92d26 AG |
858 | { |
859 | INIT_LIST_HEAD(&event->list); | |
a0a92d26 | 860 | } |
b4e4e140 | 861 | |
90586523 EP |
862 | #else |
863 | ||
40a100d3 AG |
864 | static inline int fsnotify(__u32 mask, const void *data, int data_type, |
865 | struct inode *dir, const struct qstr *name, | |
866 | struct inode *inode, u32 cookie) | |
c4ec54b4 EP |
867 | { |
868 | return 0; | |
869 | } | |
3be25f49 | 870 | |
71d73410 | 871 | static inline int __fsnotify_parent(struct dentry *dentry, __u32 mask, |
017de65f | 872 | const void *data, int data_type) |
52420392 EP |
873 | { |
874 | return 0; | |
875 | } | |
c28f7e56 | 876 | |
3be25f49 EP |
877 | static inline void __fsnotify_inode_delete(struct inode *inode) |
878 | {} | |
879 | ||
ca9c726e AG |
880 | static inline void __fsnotify_vfsmount_delete(struct vfsmount *mnt) |
881 | {} | |
882 | ||
1e6cb723 AG |
883 | static inline void fsnotify_sb_delete(struct super_block *sb) |
884 | {} | |
885 | ||
795bb82d AG |
886 | static inline void fsnotify_sb_free(struct super_block *sb) |
887 | {} | |
888 | ||
affda484 | 889 | static inline void fsnotify_update_flags(struct dentry *dentry) |
c28f7e56 EP |
890 | {} |
891 | ||
47882c6f EP |
892 | static inline u32 fsnotify_get_cookie(void) |
893 | { | |
894 | return 0; | |
895 | } | |
896 | ||
74278da9 | 897 | static inline void fsnotify_unmount_inodes(struct super_block *sb) |
164bc619 EP |
898 | {} |
899 | ||
90586523 EP |
900 | #endif /* CONFIG_FSNOTIFY */ |
901 | ||
902 | #endif /* __KERNEL __ */ | |
903 | ||
904 | #endif /* __LINUX_FSNOTIFY_BACKEND_H */ |