0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __LINUX_FSNOTIFY_BACKEND_H
0009 #define __LINUX_FSNOTIFY_BACKEND_H
0010
0011 #ifdef __KERNEL__
0012
0013 #include <linux/idr.h> /* inotify uses this */
0014 #include <linux/fs.h> /* struct inode */
0015 #include <linux/list.h>
0016 #include <linux/path.h> /* struct path */
0017 #include <linux/spinlock.h>
0018 #include <linux/types.h>
0019 #include <linux/atomic.h>
0020 #include <linux/user_namespace.h>
0021 #include <linux/refcount.h>
0022 #include <linux/mempool.h>
0023 #include <linux/sched/mm.h>
0024
0025
0026
0027
0028
0029
0030
0031 #define FS_ACCESS 0x00000001
0032 #define FS_MODIFY 0x00000002
0033 #define FS_ATTRIB 0x00000004
0034 #define FS_CLOSE_WRITE 0x00000008
0035 #define FS_CLOSE_NOWRITE 0x00000010
0036 #define FS_OPEN 0x00000020
0037 #define FS_MOVED_FROM 0x00000040
0038 #define FS_MOVED_TO 0x00000080
0039 #define FS_CREATE 0x00000100
0040 #define FS_DELETE 0x00000200
0041 #define FS_DELETE_SELF 0x00000400
0042 #define FS_MOVE_SELF 0x00000800
0043 #define FS_OPEN_EXEC 0x00001000
0044
0045 #define FS_UNMOUNT 0x00002000
0046 #define FS_Q_OVERFLOW 0x00004000
0047 #define FS_ERROR 0x00008000
0048
0049
0050
0051
0052
0053 #define FS_IN_IGNORED 0x00008000
0054
0055 #define FS_OPEN_PERM 0x00010000
0056 #define FS_ACCESS_PERM 0x00020000
0057 #define FS_OPEN_EXEC_PERM 0x00040000
0058
0059
0060
0061
0062
0063
0064 #define FS_EVENT_ON_CHILD 0x08000000
0065
0066 #define FS_RENAME 0x10000000
0067 #define FS_DN_MULTISHOT 0x20000000
0068 #define FS_ISDIR 0x40000000
0069
0070 #define FS_MOVE (FS_MOVED_FROM | FS_MOVED_TO)
0071
0072
0073
0074
0075
0076
0077
0078 #define ALL_FSNOTIFY_DIRENT_EVENTS (FS_CREATE | FS_DELETE | FS_MOVE | FS_RENAME)
0079
0080 #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM | \
0081 FS_OPEN_EXEC_PERM)
0082
0083
0084
0085
0086
0087 #define FS_EVENTS_POSS_ON_CHILD (ALL_FSNOTIFY_PERM_EVENTS | \
0088 FS_ACCESS | FS_MODIFY | FS_ATTRIB | \
0089 FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | \
0090 FS_OPEN | FS_OPEN_EXEC)
0091
0092
0093
0094
0095
0096
0097
0098 #define FS_EVENTS_POSS_TO_PARENT (FS_EVENTS_POSS_ON_CHILD)
0099
0100
0101 #define ALL_FSNOTIFY_EVENTS (ALL_FSNOTIFY_DIRENT_EVENTS | \
0102 FS_EVENTS_POSS_ON_CHILD | \
0103 FS_DELETE_SELF | FS_MOVE_SELF | \
0104 FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \
0105 FS_ERROR)
0106
0107
0108 #define ALL_FSNOTIFY_FLAGS (FS_ISDIR | FS_EVENT_ON_CHILD | FS_DN_MULTISHOT)
0109
0110 #define ALL_FSNOTIFY_BITS (ALL_FSNOTIFY_EVENTS | ALL_FSNOTIFY_FLAGS)
0111
0112 struct fsnotify_group;
0113 struct fsnotify_event;
0114 struct fsnotify_mark;
0115 struct fsnotify_event_private_data;
0116 struct fsnotify_fname;
0117 struct fsnotify_iter_info;
0118
0119 struct mem_cgroup;
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155 struct fsnotify_ops {
0156 int (*handle_event)(struct fsnotify_group *group, u32 mask,
0157 const void *data, int data_type, struct inode *dir,
0158 const struct qstr *file_name, u32 cookie,
0159 struct fsnotify_iter_info *iter_info);
0160 int (*handle_inode_event)(struct fsnotify_mark *mark, u32 mask,
0161 struct inode *inode, struct inode *dir,
0162 const struct qstr *file_name, u32 cookie);
0163 void (*free_group_priv)(struct fsnotify_group *group);
0164 void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
0165 void (*free_event)(struct fsnotify_group *group, struct fsnotify_event *event);
0166
0167 void (*free_mark)(struct fsnotify_mark *mark);
0168 };
0169
0170
0171
0172
0173
0174
0175 struct fsnotify_event {
0176 struct list_head list;
0177 };
0178
0179
0180
0181
0182
0183
0184
0185 struct fsnotify_group {
0186 const struct fsnotify_ops *ops;
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196 refcount_t refcnt;
0197
0198
0199 spinlock_t notification_lock;
0200 struct list_head notification_list;
0201 wait_queue_head_t notification_waitq;
0202 unsigned int q_len;
0203 unsigned int max_events;
0204
0205
0206
0207
0208 #define FS_PRIO_0 0
0209 #define FS_PRIO_1 1
0210 #define FS_PRIO_2 2
0211 unsigned int priority;
0212 bool shutdown;
0213
0214 #define FSNOTIFY_GROUP_USER 0x01
0215 #define FSNOTIFY_GROUP_DUPS 0x02
0216 #define FSNOTIFY_GROUP_NOFS 0x04
0217 int flags;
0218 unsigned int owner_flags;
0219
0220
0221 struct mutex mark_mutex;
0222 atomic_t user_waits;
0223
0224 struct list_head marks_list;
0225
0226 struct fasync_struct *fsn_fa;
0227
0228 struct fsnotify_event *overflow_event;
0229
0230
0231
0232 struct mem_cgroup *memcg;
0233
0234
0235 union {
0236 void *private;
0237 #ifdef CONFIG_INOTIFY_USER
0238 struct inotify_group_private_data {
0239 spinlock_t idr_lock;
0240 struct idr idr;
0241 struct ucounts *ucounts;
0242 } inotify_data;
0243 #endif
0244 #ifdef CONFIG_FANOTIFY
0245 struct fanotify_group_private_data {
0246
0247 struct hlist_head *merge_hash;
0248
0249 struct list_head access_list;
0250 wait_queue_head_t access_waitq;
0251 int flags;
0252 int f_flags;
0253 struct ucounts *ucounts;
0254 mempool_t error_events_pool;
0255 } fanotify_data;
0256 #endif
0257 };
0258 };
0259
0260
0261
0262
0263
0264 static inline void fsnotify_group_lock(struct fsnotify_group *group)
0265 {
0266 mutex_lock(&group->mark_mutex);
0267 if (group->flags & FSNOTIFY_GROUP_NOFS)
0268 group->owner_flags = memalloc_nofs_save();
0269 }
0270
0271 static inline void fsnotify_group_unlock(struct fsnotify_group *group)
0272 {
0273 if (group->flags & FSNOTIFY_GROUP_NOFS)
0274 memalloc_nofs_restore(group->owner_flags);
0275 mutex_unlock(&group->mark_mutex);
0276 }
0277
0278 static inline void fsnotify_group_assert_locked(struct fsnotify_group *group)
0279 {
0280 WARN_ON_ONCE(!mutex_is_locked(&group->mark_mutex));
0281 if (group->flags & FSNOTIFY_GROUP_NOFS)
0282 WARN_ON_ONCE(!(current->flags & PF_MEMALLOC_NOFS));
0283 }
0284
0285
0286 enum fsnotify_data_type {
0287 FSNOTIFY_EVENT_NONE,
0288 FSNOTIFY_EVENT_PATH,
0289 FSNOTIFY_EVENT_INODE,
0290 FSNOTIFY_EVENT_DENTRY,
0291 FSNOTIFY_EVENT_ERROR,
0292 };
0293
0294 struct fs_error_report {
0295 int error;
0296 struct inode *inode;
0297 struct super_block *sb;
0298 };
0299
0300 static inline struct inode *fsnotify_data_inode(const void *data, int data_type)
0301 {
0302 switch (data_type) {
0303 case FSNOTIFY_EVENT_INODE:
0304 return (struct inode *)data;
0305 case FSNOTIFY_EVENT_DENTRY:
0306 return d_inode(data);
0307 case FSNOTIFY_EVENT_PATH:
0308 return d_inode(((const struct path *)data)->dentry);
0309 case FSNOTIFY_EVENT_ERROR:
0310 return ((struct fs_error_report *)data)->inode;
0311 default:
0312 return NULL;
0313 }
0314 }
0315
0316 static inline struct dentry *fsnotify_data_dentry(const void *data, int data_type)
0317 {
0318 switch (data_type) {
0319 case FSNOTIFY_EVENT_DENTRY:
0320
0321 return (struct dentry *)data;
0322 case FSNOTIFY_EVENT_PATH:
0323 return ((const struct path *)data)->dentry;
0324 default:
0325 return NULL;
0326 }
0327 }
0328
0329 static inline const struct path *fsnotify_data_path(const void *data,
0330 int data_type)
0331 {
0332 switch (data_type) {
0333 case FSNOTIFY_EVENT_PATH:
0334 return data;
0335 default:
0336 return NULL;
0337 }
0338 }
0339
0340 static inline struct super_block *fsnotify_data_sb(const void *data,
0341 int data_type)
0342 {
0343 switch (data_type) {
0344 case FSNOTIFY_EVENT_INODE:
0345 return ((struct inode *)data)->i_sb;
0346 case FSNOTIFY_EVENT_DENTRY:
0347 return ((struct dentry *)data)->d_sb;
0348 case FSNOTIFY_EVENT_PATH:
0349 return ((const struct path *)data)->dentry->d_sb;
0350 case FSNOTIFY_EVENT_ERROR:
0351 return ((struct fs_error_report *) data)->sb;
0352 default:
0353 return NULL;
0354 }
0355 }
0356
0357 static inline struct fs_error_report *fsnotify_data_error_report(
0358 const void *data,
0359 int data_type)
0360 {
0361 switch (data_type) {
0362 case FSNOTIFY_EVENT_ERROR:
0363 return (struct fs_error_report *) data;
0364 default:
0365 return NULL;
0366 }
0367 }
0368
0369
0370
0371
0372
0373
0374
0375
0376 enum fsnotify_iter_type {
0377 FSNOTIFY_ITER_TYPE_INODE,
0378 FSNOTIFY_ITER_TYPE_VFSMOUNT,
0379 FSNOTIFY_ITER_TYPE_SB,
0380 FSNOTIFY_ITER_TYPE_PARENT,
0381 FSNOTIFY_ITER_TYPE_INODE2,
0382 FSNOTIFY_ITER_TYPE_COUNT
0383 };
0384
0385
0386 enum fsnotify_obj_type {
0387 FSNOTIFY_OBJ_TYPE_ANY = -1,
0388 FSNOTIFY_OBJ_TYPE_INODE,
0389 FSNOTIFY_OBJ_TYPE_VFSMOUNT,
0390 FSNOTIFY_OBJ_TYPE_SB,
0391 FSNOTIFY_OBJ_TYPE_COUNT,
0392 FSNOTIFY_OBJ_TYPE_DETACHED = FSNOTIFY_OBJ_TYPE_COUNT
0393 };
0394
0395 static inline bool fsnotify_valid_obj_type(unsigned int obj_type)
0396 {
0397 return (obj_type < FSNOTIFY_OBJ_TYPE_COUNT);
0398 }
0399
0400 struct fsnotify_iter_info {
0401 struct fsnotify_mark *marks[FSNOTIFY_ITER_TYPE_COUNT];
0402 struct fsnotify_group *current_group;
0403 unsigned int report_mask;
0404 int srcu_idx;
0405 };
0406
0407 static inline bool fsnotify_iter_should_report_type(
0408 struct fsnotify_iter_info *iter_info, int iter_type)
0409 {
0410 return (iter_info->report_mask & (1U << iter_type));
0411 }
0412
0413 static inline void fsnotify_iter_set_report_type(
0414 struct fsnotify_iter_info *iter_info, int iter_type)
0415 {
0416 iter_info->report_mask |= (1U << iter_type);
0417 }
0418
0419 static inline struct fsnotify_mark *fsnotify_iter_mark(
0420 struct fsnotify_iter_info *iter_info, int iter_type)
0421 {
0422 if (fsnotify_iter_should_report_type(iter_info, iter_type))
0423 return iter_info->marks[iter_type];
0424 return NULL;
0425 }
0426
0427 static inline int fsnotify_iter_step(struct fsnotify_iter_info *iter, int type,
0428 struct fsnotify_mark **markp)
0429 {
0430 while (type < FSNOTIFY_ITER_TYPE_COUNT) {
0431 *markp = fsnotify_iter_mark(iter, type);
0432 if (*markp)
0433 break;
0434 type++;
0435 }
0436 return type;
0437 }
0438
0439 #define FSNOTIFY_ITER_FUNCS(name, NAME) \
0440 static inline struct fsnotify_mark *fsnotify_iter_##name##_mark( \
0441 struct fsnotify_iter_info *iter_info) \
0442 { \
0443 return fsnotify_iter_mark(iter_info, FSNOTIFY_ITER_TYPE_##NAME); \
0444 }
0445
0446 FSNOTIFY_ITER_FUNCS(inode, INODE)
0447 FSNOTIFY_ITER_FUNCS(parent, PARENT)
0448 FSNOTIFY_ITER_FUNCS(vfsmount, VFSMOUNT)
0449 FSNOTIFY_ITER_FUNCS(sb, SB)
0450
0451 #define fsnotify_foreach_iter_type(type) \
0452 for (type = 0; type < FSNOTIFY_ITER_TYPE_COUNT; type++)
0453 #define fsnotify_foreach_iter_mark_type(iter, mark, type) \
0454 for (type = 0; \
0455 type = fsnotify_iter_step(iter, type, &mark), \
0456 type < FSNOTIFY_ITER_TYPE_COUNT; \
0457 type++)
0458
0459
0460
0461
0462
0463 struct fsnotify_mark_connector;
0464 typedef struct fsnotify_mark_connector __rcu *fsnotify_connp_t;
0465
0466
0467
0468
0469
0470
0471
0472 struct fsnotify_mark_connector {
0473 spinlock_t lock;
0474 unsigned short type;
0475 #define FSNOTIFY_CONN_FLAG_HAS_FSID 0x01
0476 #define FSNOTIFY_CONN_FLAG_HAS_IREF 0x02
0477 unsigned short flags;
0478 __kernel_fsid_t fsid;
0479 union {
0480
0481 fsnotify_connp_t *obj;
0482
0483 struct fsnotify_mark_connector *destroy_next;
0484 };
0485 struct hlist_head list;
0486 };
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502 struct fsnotify_mark {
0503
0504 __u32 mask;
0505
0506
0507 refcount_t refcnt;
0508
0509
0510 struct fsnotify_group *group;
0511
0512
0513
0514 struct list_head g_list;
0515
0516 spinlock_t lock;
0517
0518 struct hlist_node obj_list;
0519
0520 struct fsnotify_mark_connector *connector;
0521
0522 __u32 ignore_mask;
0523
0524 #define FSNOTIFY_MARK_FLAG_ALIVE 0x0001
0525 #define FSNOTIFY_MARK_FLAG_ATTACHED 0x0002
0526
0527 #define FSNOTIFY_MARK_FLAG_EXCL_UNLINK 0x0010
0528 #define FSNOTIFY_MARK_FLAG_IN_ONESHOT 0x0020
0529
0530 #define FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY 0x0100
0531 #define FSNOTIFY_MARK_FLAG_NO_IREF 0x0200
0532 #define FSNOTIFY_MARK_FLAG_HAS_IGNORE_FLAGS 0x0400
0533 unsigned int flags;
0534 };
0535
0536 #ifdef CONFIG_FSNOTIFY
0537
0538
0539
0540
0541 extern int fsnotify(__u32 mask, const void *data, int data_type,
0542 struct inode *dir, const struct qstr *name,
0543 struct inode *inode, u32 cookie);
0544 extern int __fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data,
0545 int data_type);
0546 extern void __fsnotify_inode_delete(struct inode *inode);
0547 extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
0548 extern void fsnotify_sb_delete(struct super_block *sb);
0549 extern u32 fsnotify_get_cookie(void);
0550
0551 static inline __u32 fsnotify_parent_needed_mask(__u32 mask)
0552 {
0553
0554 if (!(mask & FS_EVENT_ON_CHILD))
0555 return 0;
0556
0557
0558
0559
0560
0561 return mask & FS_EVENTS_POSS_TO_PARENT;
0562 }
0563
0564 static inline int fsnotify_inode_watches_children(struct inode *inode)
0565 {
0566
0567 if (!(inode->i_fsnotify_mask & FS_EVENT_ON_CHILD))
0568 return 0;
0569
0570
0571 return inode->i_fsnotify_mask & FS_EVENTS_POSS_ON_CHILD;
0572 }
0573
0574
0575
0576
0577
0578 static inline void fsnotify_update_flags(struct dentry *dentry)
0579 {
0580 assert_spin_locked(&dentry->d_lock);
0581
0582
0583
0584
0585
0586
0587
0588
0589 if (fsnotify_inode_watches_children(dentry->d_parent->d_inode))
0590 dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED;
0591 else
0592 dentry->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED;
0593 }
0594
0595
0596
0597
0598 extern struct fsnotify_group *fsnotify_alloc_group(
0599 const struct fsnotify_ops *ops,
0600 int flags);
0601
0602 extern void fsnotify_get_group(struct fsnotify_group *group);
0603
0604 extern void fsnotify_put_group(struct fsnotify_group *group);
0605
0606 extern void fsnotify_group_stop_queueing(struct fsnotify_group *group);
0607
0608 extern void fsnotify_destroy_group(struct fsnotify_group *group);
0609
0610 extern int fsnotify_fasync(int fd, struct file *file, int on);
0611
0612 extern void fsnotify_destroy_event(struct fsnotify_group *group,
0613 struct fsnotify_event *event);
0614
0615 extern int fsnotify_insert_event(struct fsnotify_group *group,
0616 struct fsnotify_event *event,
0617 int (*merge)(struct fsnotify_group *,
0618 struct fsnotify_event *),
0619 void (*insert)(struct fsnotify_group *,
0620 struct fsnotify_event *));
0621
0622 static inline int fsnotify_add_event(struct fsnotify_group *group,
0623 struct fsnotify_event *event,
0624 int (*merge)(struct fsnotify_group *,
0625 struct fsnotify_event *))
0626 {
0627 return fsnotify_insert_event(group, event, merge, NULL);
0628 }
0629
0630
0631 static inline void fsnotify_queue_overflow(struct fsnotify_group *group)
0632 {
0633 fsnotify_add_event(group, group->overflow_event, NULL);
0634 }
0635
0636 static inline bool fsnotify_is_overflow_event(u32 mask)
0637 {
0638 return mask & FS_Q_OVERFLOW;
0639 }
0640
0641 static inline bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group)
0642 {
0643 assert_spin_locked(&group->notification_lock);
0644
0645 return list_empty(&group->notification_list);
0646 }
0647
0648 extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group);
0649
0650 extern struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group);
0651
0652 extern struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group);
0653
0654 extern void fsnotify_remove_queued_event(struct fsnotify_group *group,
0655 struct fsnotify_event *event);
0656
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666
0667 static inline __u32 fsnotify_ignore_mask(struct fsnotify_mark *mark)
0668 {
0669 __u32 ignore_mask = mark->ignore_mask;
0670
0671
0672 if (mark->flags & FSNOTIFY_MARK_FLAG_HAS_IGNORE_FLAGS)
0673 return ignore_mask;
0674
0675
0676
0677
0678
0679
0680 ignore_mask |= FS_ISDIR;
0681 ignore_mask &= ~FS_EVENT_ON_CHILD;
0682 ignore_mask |= mark->mask & FS_EVENT_ON_CHILD;
0683
0684 return ignore_mask;
0685 }
0686
0687
0688 static inline __u32 fsnotify_ignored_events(struct fsnotify_mark *mark)
0689 {
0690 return mark->ignore_mask & ALL_FSNOTIFY_EVENTS;
0691 }
0692
0693
0694
0695
0696
0697 static inline bool fsnotify_mask_applicable(__u32 mask, bool is_dir,
0698 int iter_type)
0699 {
0700
0701 if (is_dir && !(mask & FS_ISDIR))
0702 return false;
0703
0704
0705 if (iter_type == FSNOTIFY_ITER_TYPE_PARENT &&
0706 !(mask & FS_EVENT_ON_CHILD))
0707 return false;
0708
0709 return true;
0710 }
0711
0712
0713
0714
0715
0716 static inline __u32 fsnotify_effective_ignore_mask(struct fsnotify_mark *mark,
0717 bool is_dir, int iter_type)
0718 {
0719 __u32 ignore_mask = fsnotify_ignored_events(mark);
0720
0721 if (!ignore_mask)
0722 return 0;
0723
0724
0725 if (!is_dir && iter_type != FSNOTIFY_ITER_TYPE_PARENT)
0726 return ignore_mask;
0727
0728 ignore_mask = fsnotify_ignore_mask(mark);
0729 if (!fsnotify_mask_applicable(ignore_mask, is_dir, iter_type))
0730 return 0;
0731
0732 return ignore_mask & ALL_FSNOTIFY_EVENTS;
0733 }
0734
0735
0736 static inline __u32 fsnotify_calc_mask(struct fsnotify_mark *mark)
0737 {
0738 __u32 mask = mark->mask;
0739
0740 if (!fsnotify_ignored_events(mark))
0741 return mask;
0742
0743
0744 if (!(mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY))
0745 mask |= FS_MODIFY;
0746
0747
0748
0749
0750
0751 return mask | mark->ignore_mask;
0752 }
0753
0754
0755 extern __u32 fsnotify_conn_mask(struct fsnotify_mark_connector *conn);
0756
0757 extern void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn);
0758 extern void fsnotify_init_mark(struct fsnotify_mark *mark,
0759 struct fsnotify_group *group);
0760
0761 extern struct fsnotify_mark *fsnotify_find_mark(fsnotify_connp_t *connp,
0762 struct fsnotify_group *group);
0763
0764 extern int fsnotify_get_conn_fsid(const struct fsnotify_mark_connector *conn,
0765 __kernel_fsid_t *fsid);
0766
0767 extern int fsnotify_add_mark(struct fsnotify_mark *mark,
0768 fsnotify_connp_t *connp, unsigned int obj_type,
0769 int add_flags, __kernel_fsid_t *fsid);
0770 extern int fsnotify_add_mark_locked(struct fsnotify_mark *mark,
0771 fsnotify_connp_t *connp,
0772 unsigned int obj_type, int add_flags,
0773 __kernel_fsid_t *fsid);
0774
0775
0776 static inline int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
0777 struct inode *inode,
0778 int add_flags)
0779 {
0780 return fsnotify_add_mark(mark, &inode->i_fsnotify_marks,
0781 FSNOTIFY_OBJ_TYPE_INODE, add_flags, NULL);
0782 }
0783 static inline int fsnotify_add_inode_mark_locked(struct fsnotify_mark *mark,
0784 struct inode *inode,
0785 int add_flags)
0786 {
0787 return fsnotify_add_mark_locked(mark, &inode->i_fsnotify_marks,
0788 FSNOTIFY_OBJ_TYPE_INODE, add_flags,
0789 NULL);
0790 }
0791
0792
0793 extern void fsnotify_destroy_mark(struct fsnotify_mark *mark,
0794 struct fsnotify_group *group);
0795
0796 extern void fsnotify_detach_mark(struct fsnotify_mark *mark);
0797
0798 extern void fsnotify_free_mark(struct fsnotify_mark *mark);
0799
0800 extern void fsnotify_wait_marks_destroyed(void);
0801
0802 extern void fsnotify_clear_marks_by_group(struct fsnotify_group *group,
0803 unsigned int obj_type);
0804
0805 static inline void fsnotify_clear_vfsmount_marks_by_group(struct fsnotify_group *group)
0806 {
0807 fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_VFSMOUNT);
0808 }
0809
0810 static inline void fsnotify_clear_inode_marks_by_group(struct fsnotify_group *group)
0811 {
0812 fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_INODE);
0813 }
0814
0815 static inline void fsnotify_clear_sb_marks_by_group(struct fsnotify_group *group)
0816 {
0817 fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_SB);
0818 }
0819 extern void fsnotify_get_mark(struct fsnotify_mark *mark);
0820 extern void fsnotify_put_mark(struct fsnotify_mark *mark);
0821 extern void fsnotify_finish_user_wait(struct fsnotify_iter_info *iter_info);
0822 extern bool fsnotify_prepare_user_wait(struct fsnotify_iter_info *iter_info);
0823
0824 static inline void fsnotify_init_event(struct fsnotify_event *event)
0825 {
0826 INIT_LIST_HEAD(&event->list);
0827 }
0828
0829 #else
0830
0831 static inline int fsnotify(__u32 mask, const void *data, int data_type,
0832 struct inode *dir, const struct qstr *name,
0833 struct inode *inode, u32 cookie)
0834 {
0835 return 0;
0836 }
0837
0838 static inline int __fsnotify_parent(struct dentry *dentry, __u32 mask,
0839 const void *data, int data_type)
0840 {
0841 return 0;
0842 }
0843
0844 static inline void __fsnotify_inode_delete(struct inode *inode)
0845 {}
0846
0847 static inline void __fsnotify_vfsmount_delete(struct vfsmount *mnt)
0848 {}
0849
0850 static inline void fsnotify_sb_delete(struct super_block *sb)
0851 {}
0852
0853 static inline void fsnotify_update_flags(struct dentry *dentry)
0854 {}
0855
0856 static inline u32 fsnotify_get_cookie(void)
0857 {
0858 return 0;
0859 }
0860
0861 static inline void fsnotify_unmount_inodes(struct super_block *sb)
0862 {}
0863
0864 #endif
0865
0866 #endif
0867
0868 #endif