aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fsnotify_backend.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/fsnotify_backend.h')
-rw-r--r--include/linux/fsnotify_backend.h79
1 files changed, 69 insertions, 10 deletions
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index e64c0294f50b..b38964a7a521 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -98,8 +98,6 @@ struct fsnotify_iter_info;
98struct fsnotify_ops { 98struct fsnotify_ops {
99 int (*handle_event)(struct fsnotify_group *group, 99 int (*handle_event)(struct fsnotify_group *group,
100 struct inode *inode, 100 struct inode *inode,
101 struct fsnotify_mark *inode_mark,
102 struct fsnotify_mark *vfsmount_mark,
103 u32 mask, const void *data, int data_type, 101 u32 mask, const void *data, int data_type,
104 const unsigned char *file_name, u32 cookie, 102 const unsigned char *file_name, u32 cookie,
105 struct fsnotify_iter_info *iter_info); 103 struct fsnotify_iter_info *iter_info);
@@ -201,6 +199,57 @@ struct fsnotify_group {
201#define FSNOTIFY_EVENT_PATH 1 199#define FSNOTIFY_EVENT_PATH 1
202#define FSNOTIFY_EVENT_INODE 2 200#define FSNOTIFY_EVENT_INODE 2
203 201
202enum fsnotify_obj_type {
203 FSNOTIFY_OBJ_TYPE_INODE,
204 FSNOTIFY_OBJ_TYPE_VFSMOUNT,
205 FSNOTIFY_OBJ_TYPE_COUNT,
206 FSNOTIFY_OBJ_TYPE_DETACHED = FSNOTIFY_OBJ_TYPE_COUNT
207};
208
209#define FSNOTIFY_OBJ_TYPE_INODE_FL (1U << FSNOTIFY_OBJ_TYPE_INODE)
210#define FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL (1U << FSNOTIFY_OBJ_TYPE_VFSMOUNT)
211#define FSNOTIFY_OBJ_ALL_TYPES_MASK ((1U << FSNOTIFY_OBJ_TYPE_COUNT) - 1)
212
213struct fsnotify_iter_info {
214 struct fsnotify_mark *marks[FSNOTIFY_OBJ_TYPE_COUNT];
215 unsigned int report_mask;
216 int srcu_idx;
217};
218
219static inline bool fsnotify_iter_should_report_type(
220 struct fsnotify_iter_info *iter_info, int type)
221{
222 return (iter_info->report_mask & (1U << type));
223}
224
225static inline void fsnotify_iter_set_report_type(
226 struct fsnotify_iter_info *iter_info, int type)
227{
228 iter_info->report_mask |= (1U << type);
229}
230
231static inline void fsnotify_iter_set_report_type_mark(
232 struct fsnotify_iter_info *iter_info, int type,
233 struct fsnotify_mark *mark)
234{
235 iter_info->marks[type] = mark;
236 iter_info->report_mask |= (1U << type);
237}
238
239#define FSNOTIFY_ITER_FUNCS(name, NAME) \
240static inline struct fsnotify_mark *fsnotify_iter_##name##_mark( \
241 struct fsnotify_iter_info *iter_info) \
242{ \
243 return (iter_info->report_mask & FSNOTIFY_OBJ_TYPE_##NAME##_FL) ? \
244 iter_info->marks[FSNOTIFY_OBJ_TYPE_##NAME] : NULL; \
245}
246
247FSNOTIFY_ITER_FUNCS(inode, INODE)
248FSNOTIFY_ITER_FUNCS(vfsmount, VFSMOUNT)
249
250#define fsnotify_foreach_obj_type(type) \
251 for (type = 0; type < FSNOTIFY_OBJ_TYPE_COUNT; type++)
252
204/* 253/*
205 * Inode / vfsmount point to this structure which tracks all marks attached to 254 * Inode / vfsmount point to this structure which tracks all marks attached to
206 * the inode / vfsmount. The reference to inode / vfsmount is held by this 255 * the inode / vfsmount. The reference to inode / vfsmount is held by this
@@ -209,11 +258,7 @@ struct fsnotify_group {
209 */ 258 */
210struct fsnotify_mark_connector { 259struct fsnotify_mark_connector {
211 spinlock_t lock; 260 spinlock_t lock;
212#define FSNOTIFY_OBJ_TYPE_INODE 0x01 261 unsigned int type; /* Type of object [lock] */
213#define FSNOTIFY_OBJ_TYPE_VFSMOUNT 0x02
214#define FSNOTIFY_OBJ_ALL_TYPES (FSNOTIFY_OBJ_TYPE_INODE | \
215 FSNOTIFY_OBJ_TYPE_VFSMOUNT)
216 unsigned int flags; /* Type of object [lock] */
217 union { /* Object pointer [lock] */ 262 union { /* Object pointer [lock] */
218 struct inode *inode; 263 struct inode *inode;
219 struct vfsmount *mnt; 264 struct vfsmount *mnt;
@@ -356,7 +401,21 @@ extern struct fsnotify_mark *fsnotify_find_mark(
356extern int fsnotify_add_mark(struct fsnotify_mark *mark, struct inode *inode, 401extern int fsnotify_add_mark(struct fsnotify_mark *mark, struct inode *inode,
357 struct vfsmount *mnt, int allow_dups); 402 struct vfsmount *mnt, int allow_dups);
358extern int fsnotify_add_mark_locked(struct fsnotify_mark *mark, 403extern int fsnotify_add_mark_locked(struct fsnotify_mark *mark,
359 struct inode *inode, struct vfsmount *mnt, int allow_dups); 404 struct inode *inode, struct vfsmount *mnt,
405 int allow_dups);
406/* attach the mark to the inode */
407static inline int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
408 struct inode *inode,
409 int allow_dups)
410{
411 return fsnotify_add_mark(mark, inode, NULL, allow_dups);
412}
413static inline int fsnotify_add_inode_mark_locked(struct fsnotify_mark *mark,
414 struct inode *inode,
415 int allow_dups)
416{
417 return fsnotify_add_mark_locked(mark, inode, NULL, allow_dups);
418}
360/* given a group and a mark, flag mark to be freed when all references are dropped */ 419/* given a group and a mark, flag mark to be freed when all references are dropped */
361extern void fsnotify_destroy_mark(struct fsnotify_mark *mark, 420extern void fsnotify_destroy_mark(struct fsnotify_mark *mark,
362 struct fsnotify_group *group); 421 struct fsnotify_group *group);
@@ -369,12 +428,12 @@ extern void fsnotify_clear_marks_by_group(struct fsnotify_group *group, unsigned
369/* run all the marks in a group, and clear all of the vfsmount marks */ 428/* run all the marks in a group, and clear all of the vfsmount marks */
370static inline void fsnotify_clear_vfsmount_marks_by_group(struct fsnotify_group *group) 429static inline void fsnotify_clear_vfsmount_marks_by_group(struct fsnotify_group *group)
371{ 430{
372 fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_VFSMOUNT); 431 fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL);
373} 432}
374/* run all the marks in a group, and clear all of the inode marks */ 433/* run all the marks in a group, and clear all of the inode marks */
375static inline void fsnotify_clear_inode_marks_by_group(struct fsnotify_group *group) 434static inline void fsnotify_clear_inode_marks_by_group(struct fsnotify_group *group)
376{ 435{
377 fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_INODE); 436 fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_INODE_FL);
378} 437}
379extern void fsnotify_get_mark(struct fsnotify_mark *mark); 438extern void fsnotify_get_mark(struct fsnotify_mark *mark);
380extern void fsnotify_put_mark(struct fsnotify_mark *mark); 439extern void fsnotify_put_mark(struct fsnotify_mark *mark);