~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/mount.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #include <linux/mount.h>
  3 #include <linux/seq_file.h>
  4 #include <linux/poll.h>
  5 #include <linux/ns_common.h>
  6 #include <linux/fs_pin.h>
  7 
  8 struct mnt_namespace {
  9         struct ns_common        ns;
 10         struct mount *  root;
 11         struct rb_root          mounts; /* Protected by namespace_sem */
 12         struct user_namespace   *user_ns;
 13         struct ucounts          *ucounts;
 14         u64                     seq;    /* Sequence number to prevent loops */
 15         wait_queue_head_t poll;
 16         u64 event;
 17         unsigned int            nr_mounts; /* # of mounts in the namespace */
 18         unsigned int            pending_mounts;
 19         struct rb_node          mnt_ns_tree_node; /* node in the mnt_ns_tree */
 20         refcount_t              passive; /* number references not pinning @mounts */
 21 } __randomize_layout;
 22 
 23 struct mnt_pcp {
 24         int mnt_count;
 25         int mnt_writers;
 26 };
 27 
 28 struct mountpoint {
 29         struct hlist_node m_hash;
 30         struct dentry *m_dentry;
 31         struct hlist_head m_list;
 32         int m_count;
 33 };
 34 
 35 struct mount {
 36         struct hlist_node mnt_hash;
 37         struct mount *mnt_parent;
 38         struct dentry *mnt_mountpoint;
 39         struct vfsmount mnt;
 40         union {
 41                 struct rcu_head mnt_rcu;
 42                 struct llist_node mnt_llist;
 43         };
 44 #ifdef CONFIG_SMP
 45         struct mnt_pcp __percpu *mnt_pcp;
 46 #else
 47         int mnt_count;
 48         int mnt_writers;
 49 #endif
 50         struct list_head mnt_mounts;    /* list of children, anchored here */
 51         struct list_head mnt_child;     /* and going through their mnt_child */
 52         struct list_head mnt_instance;  /* mount instance on sb->s_mounts */
 53         const char *mnt_devname;        /* Name of device e.g. /dev/dsk/hda1 */
 54         union {
 55                 struct rb_node mnt_node;        /* Under ns->mounts */
 56                 struct list_head mnt_list;
 57         };
 58         struct list_head mnt_expire;    /* link in fs-specific expiry list */
 59         struct list_head mnt_share;     /* circular list of shared mounts */
 60         struct list_head mnt_slave_list;/* list of slave mounts */
 61         struct list_head mnt_slave;     /* slave list entry */
 62         struct mount *mnt_master;       /* slave is on master->mnt_slave_list */
 63         struct mnt_namespace *mnt_ns;   /* containing namespace */
 64         struct mountpoint *mnt_mp;      /* where is it mounted */
 65         union {
 66                 struct hlist_node mnt_mp_list;  /* list mounts with the same mountpoint */
 67                 struct hlist_node mnt_umount;
 68         };
 69         struct list_head mnt_umounting; /* list entry for umount propagation */
 70 #ifdef CONFIG_FSNOTIFY
 71         struct fsnotify_mark_connector __rcu *mnt_fsnotify_marks;
 72         __u32 mnt_fsnotify_mask;
 73 #endif
 74         int mnt_id;                     /* mount identifier, reused */
 75         u64 mnt_id_unique;              /* mount ID unique until reboot */
 76         int mnt_group_id;               /* peer group identifier */
 77         int mnt_expiry_mark;            /* true if marked for expiry */
 78         struct hlist_head mnt_pins;
 79         struct hlist_head mnt_stuck_children;
 80 } __randomize_layout;
 81 
 82 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
 83 
 84 static inline struct mount *real_mount(struct vfsmount *mnt)
 85 {
 86         return container_of(mnt, struct mount, mnt);
 87 }
 88 
 89 static inline int mnt_has_parent(struct mount *mnt)
 90 {
 91         return mnt != mnt->mnt_parent;
 92 }
 93 
 94 static inline int is_mounted(struct vfsmount *mnt)
 95 {
 96         /* neither detached nor internal? */
 97         return !IS_ERR_OR_NULL(real_mount(mnt)->mnt_ns);
 98 }
 99 
100 extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *);
101 
102 extern int __legitimize_mnt(struct vfsmount *, unsigned);
103 
104 static inline bool __path_is_mountpoint(const struct path *path)
105 {
106         struct mount *m = __lookup_mnt(path->mnt, path->dentry);
107         return m && likely(!(m->mnt.mnt_flags & MNT_SYNC_UMOUNT));
108 }
109 
110 extern void __detach_mounts(struct dentry *dentry);
111 
112 static inline void detach_mounts(struct dentry *dentry)
113 {
114         if (!d_mountpoint(dentry))
115                 return;
116         __detach_mounts(dentry);
117 }
118 
119 static inline void get_mnt_ns(struct mnt_namespace *ns)
120 {
121         refcount_inc(&ns->ns.count);
122 }
123 
124 extern seqlock_t mount_lock;
125 
126 struct proc_mounts {
127         struct mnt_namespace *ns;
128         struct path root;
129         int (*show)(struct seq_file *, struct vfsmount *);
130 };
131 
132 extern const struct seq_operations mounts_op;
133 
134 extern bool __is_local_mountpoint(struct dentry *dentry);
135 static inline bool is_local_mountpoint(struct dentry *dentry)
136 {
137         if (!d_mountpoint(dentry))
138                 return false;
139 
140         return __is_local_mountpoint(dentry);
141 }
142 
143 static inline bool is_anon_ns(struct mnt_namespace *ns)
144 {
145         return ns->seq == 0;
146 }
147 
148 static inline void move_from_ns(struct mount *mnt, struct list_head *dt_list)
149 {
150         WARN_ON(!(mnt->mnt.mnt_flags & MNT_ONRB));
151         mnt->mnt.mnt_flags &= ~MNT_ONRB;
152         rb_erase(&mnt->mnt_node, &mnt->mnt_ns->mounts);
153         list_add_tail(&mnt->mnt_list, dt_list);
154 }
155 
156 extern void mnt_cursor_del(struct mnt_namespace *ns, struct mount *cursor);
157 bool has_locked_children(struct mount *mnt, struct dentry *dentry);
158 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php