Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __FS_NOTIFY_FSNOTIFY_H_
0003 #define __FS_NOTIFY_FSNOTIFY_H_
0004 
0005 #include <linux/list.h>
0006 #include <linux/fsnotify.h>
0007 #include <linux/srcu.h>
0008 #include <linux/types.h>
0009 
0010 #include "../mount.h"
0011 
0012 static inline struct inode *fsnotify_conn_inode(
0013                 struct fsnotify_mark_connector *conn)
0014 {
0015     return container_of(conn->obj, struct inode, i_fsnotify_marks);
0016 }
0017 
0018 static inline struct mount *fsnotify_conn_mount(
0019                 struct fsnotify_mark_connector *conn)
0020 {
0021     return container_of(conn->obj, struct mount, mnt_fsnotify_marks);
0022 }
0023 
0024 static inline struct super_block *fsnotify_conn_sb(
0025                 struct fsnotify_mark_connector *conn)
0026 {
0027     return container_of(conn->obj, struct super_block, s_fsnotify_marks);
0028 }
0029 
0030 static inline struct super_block *fsnotify_connector_sb(
0031                 struct fsnotify_mark_connector *conn)
0032 {
0033     switch (conn->type) {
0034     case FSNOTIFY_OBJ_TYPE_INODE:
0035         return fsnotify_conn_inode(conn)->i_sb;
0036     case FSNOTIFY_OBJ_TYPE_VFSMOUNT:
0037         return fsnotify_conn_mount(conn)->mnt.mnt_sb;
0038     case FSNOTIFY_OBJ_TYPE_SB:
0039         return fsnotify_conn_sb(conn);
0040     default:
0041         return NULL;
0042     }
0043 }
0044 
0045 /* destroy all events sitting in this groups notification queue */
0046 extern void fsnotify_flush_notify(struct fsnotify_group *group);
0047 
0048 /* protects reads of inode and vfsmount marks list */
0049 extern struct srcu_struct fsnotify_mark_srcu;
0050 
0051 /* compare two groups for sorting of marks lists */
0052 extern int fsnotify_compare_groups(struct fsnotify_group *a,
0053                    struct fsnotify_group *b);
0054 
0055 /* Destroy all marks attached to an object via connector */
0056 extern void fsnotify_destroy_marks(fsnotify_connp_t *connp);
0057 /* run the list of all marks associated with inode and destroy them */
0058 static inline void fsnotify_clear_marks_by_inode(struct inode *inode)
0059 {
0060     fsnotify_destroy_marks(&inode->i_fsnotify_marks);
0061 }
0062 /* run the list of all marks associated with vfsmount and destroy them */
0063 static inline void fsnotify_clear_marks_by_mount(struct vfsmount *mnt)
0064 {
0065     fsnotify_destroy_marks(&real_mount(mnt)->mnt_fsnotify_marks);
0066 }
0067 /* run the list of all marks associated with sb and destroy them */
0068 static inline void fsnotify_clear_marks_by_sb(struct super_block *sb)
0069 {
0070     fsnotify_destroy_marks(&sb->s_fsnotify_marks);
0071 }
0072 
0073 /*
0074  * update the dentry->d_flags of all of inode's children to indicate if inode cares
0075  * about events that happen to its children.
0076  */
0077 extern void __fsnotify_update_child_dentry_flags(struct inode *inode);
0078 
0079 /* allocate and destroy and event holder to attach events to notification/access queues */
0080 extern struct fsnotify_event_holder *fsnotify_alloc_event_holder(void);
0081 extern void fsnotify_destroy_event_holder(struct fsnotify_event_holder *holder);
0082 
0083 extern struct kmem_cache *fsnotify_mark_connector_cachep;
0084 
0085 #endif  /* __FS_NOTIFY_FSNOTIFY_H_ */