Back to home page

LXR

 
 

    


0001 #include <linux/mount.h>
0002 #include <linux/seq_file.h>
0003 #include <linux/poll.h>
0004 #include <linux/ns_common.h>
0005 #include <linux/fs_pin.h>
0006 
0007 struct mnt_namespace {
0008     atomic_t        count;
0009     struct ns_common    ns;
0010     struct mount *  root;
0011     struct list_head    list;
0012     struct user_namespace   *user_ns;
0013     struct ucounts      *ucounts;
0014     u64         seq;    /* Sequence number to prevent loops */
0015     wait_queue_head_t poll;
0016     u64 event;
0017     unsigned int        mounts; /* # of mounts in the namespace */
0018     unsigned int        pending_mounts;
0019 };
0020 
0021 struct mnt_pcp {
0022     int mnt_count;
0023     int mnt_writers;
0024 };
0025 
0026 struct mountpoint {
0027     struct hlist_node m_hash;
0028     struct dentry *m_dentry;
0029     struct hlist_head m_list;
0030     int m_count;
0031 };
0032 
0033 struct mount {
0034     struct hlist_node mnt_hash;
0035     struct mount *mnt_parent;
0036     struct dentry *mnt_mountpoint;
0037     struct vfsmount mnt;
0038     union {
0039         struct rcu_head mnt_rcu;
0040         struct llist_node mnt_llist;
0041     };
0042 #ifdef CONFIG_SMP
0043     struct mnt_pcp __percpu *mnt_pcp;
0044 #else
0045     int mnt_count;
0046     int mnt_writers;
0047 #endif
0048     struct list_head mnt_mounts;    /* list of children, anchored here */
0049     struct list_head mnt_child; /* and going through their mnt_child */
0050     struct list_head mnt_instance;  /* mount instance on sb->s_mounts */
0051     const char *mnt_devname;    /* Name of device e.g. /dev/dsk/hda1 */
0052     struct list_head mnt_list;
0053     struct list_head mnt_expire;    /* link in fs-specific expiry list */
0054     struct list_head mnt_share; /* circular list of shared mounts */
0055     struct list_head mnt_slave_list;/* list of slave mounts */
0056     struct list_head mnt_slave; /* slave list entry */
0057     struct mount *mnt_master;   /* slave is on master->mnt_slave_list */
0058     struct mnt_namespace *mnt_ns;   /* containing namespace */
0059     struct mountpoint *mnt_mp;  /* where is it mounted */
0060     struct hlist_node mnt_mp_list;  /* list mounts with the same mountpoint */
0061 #ifdef CONFIG_FSNOTIFY
0062     struct hlist_head mnt_fsnotify_marks;
0063     __u32 mnt_fsnotify_mask;
0064 #endif
0065     int mnt_id;         /* mount identifier */
0066     int mnt_group_id;       /* peer group identifier */
0067     int mnt_expiry_mark;        /* true if marked for expiry */
0068     struct hlist_head mnt_pins;
0069     struct fs_pin mnt_umount;
0070     struct dentry *mnt_ex_mountpoint;
0071 };
0072 
0073 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
0074 
0075 static inline struct mount *real_mount(struct vfsmount *mnt)
0076 {
0077     return container_of(mnt, struct mount, mnt);
0078 }
0079 
0080 static inline int mnt_has_parent(struct mount *mnt)
0081 {
0082     return mnt != mnt->mnt_parent;
0083 }
0084 
0085 static inline int is_mounted(struct vfsmount *mnt)
0086 {
0087     /* neither detached nor internal? */
0088     return !IS_ERR_OR_NULL(real_mount(mnt)->mnt_ns);
0089 }
0090 
0091 extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *);
0092 extern struct mount *__lookup_mnt_last(struct vfsmount *, struct dentry *);
0093 
0094 extern int __legitimize_mnt(struct vfsmount *, unsigned);
0095 extern bool legitimize_mnt(struct vfsmount *, unsigned);
0096 
0097 static inline bool __path_is_mountpoint(const struct path *path)
0098 {
0099     struct mount *m = __lookup_mnt(path->mnt, path->dentry);
0100     return m && likely(!(m->mnt.mnt_flags & MNT_SYNC_UMOUNT));
0101 }
0102 
0103 extern void __detach_mounts(struct dentry *dentry);
0104 
0105 static inline void detach_mounts(struct dentry *dentry)
0106 {
0107     if (!d_mountpoint(dentry))
0108         return;
0109     __detach_mounts(dentry);
0110 }
0111 
0112 static inline void get_mnt_ns(struct mnt_namespace *ns)
0113 {
0114     atomic_inc(&ns->count);
0115 }
0116 
0117 extern seqlock_t mount_lock;
0118 
0119 static inline void lock_mount_hash(void)
0120 {
0121     write_seqlock(&mount_lock);
0122 }
0123 
0124 static inline void unlock_mount_hash(void)
0125 {
0126     write_sequnlock(&mount_lock);
0127 }
0128 
0129 struct proc_mounts {
0130     struct mnt_namespace *ns;
0131     struct path root;
0132     int (*show)(struct seq_file *, struct vfsmount *);
0133     void *cached_mount;
0134     u64 cached_event;
0135     loff_t cached_index;
0136 };
0137 
0138 extern const struct seq_operations mounts_op;
0139 
0140 extern bool __is_local_mountpoint(struct dentry *dentry);
0141 static inline bool is_local_mountpoint(struct dentry *dentry)
0142 {
0143     if (!d_mountpoint(dentry))
0144         return false;
0145 
0146     return __is_local_mountpoint(dentry);
0147 }