Commit | Line | Data |
---|---|---|
b2dba1af | 1 | #include <linux/mount.h> |
0226f492 AV |
2 | #include <linux/seq_file.h> |
3 | #include <linux/poll.h> | |
435d5f4b | 4 | #include <linux/ns_common.h> |
0226f492 AV |
5 | |
6 | struct mnt_namespace { | |
7 | atomic_t count; | |
435d5f4b | 8 | struct ns_common ns; |
be08d6d2 | 9 | struct mount * root; |
0226f492 | 10 | struct list_head list; |
771b1371 | 11 | struct user_namespace *user_ns; |
8823c079 | 12 | u64 seq; /* Sequence number to prevent loops */ |
0226f492 | 13 | wait_queue_head_t poll; |
c7999c36 | 14 | u64 event; |
0226f492 | 15 | }; |
b2dba1af | 16 | |
68e8a9fe AV |
17 | struct mnt_pcp { |
18 | int mnt_count; | |
19 | int mnt_writers; | |
20 | }; | |
21 | ||
84d17192 | 22 | struct mountpoint { |
0818bf27 | 23 | struct hlist_node m_hash; |
84d17192 | 24 | struct dentry *m_dentry; |
0a5eb7c8 | 25 | struct hlist_head m_list; |
84d17192 AV |
26 | int m_count; |
27 | }; | |
28 | ||
7d6fec45 | 29 | struct mount { |
38129a13 | 30 | struct hlist_node mnt_hash; |
0714a533 | 31 | struct mount *mnt_parent; |
a73324da | 32 | struct dentry *mnt_mountpoint; |
7d6fec45 | 33 | struct vfsmount mnt; |
9ea459e1 AV |
34 | union { |
35 | struct rcu_head mnt_rcu; | |
36 | struct llist_node mnt_llist; | |
37 | }; | |
68e8a9fe AV |
38 | #ifdef CONFIG_SMP |
39 | struct mnt_pcp __percpu *mnt_pcp; | |
68e8a9fe AV |
40 | #else |
41 | int mnt_count; | |
42 | int mnt_writers; | |
43 | #endif | |
6b41d536 AV |
44 | struct list_head mnt_mounts; /* list of children, anchored here */ |
45 | struct list_head mnt_child; /* and going through their mnt_child */ | |
39f7c4db | 46 | struct list_head mnt_instance; /* mount instance on sb->s_mounts */ |
52ba1621 | 47 | const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ |
1a4eeaf2 | 48 | struct list_head mnt_list; |
6776db3d AV |
49 | struct list_head mnt_expire; /* link in fs-specific expiry list */ |
50 | struct list_head mnt_share; /* circular list of shared mounts */ | |
51 | struct list_head mnt_slave_list;/* list of slave mounts */ | |
52 | struct list_head mnt_slave; /* slave list entry */ | |
32301920 | 53 | struct mount *mnt_master; /* slave is on master->mnt_slave_list */ |
143c8c91 | 54 | struct mnt_namespace *mnt_ns; /* containing namespace */ |
84d17192 | 55 | struct mountpoint *mnt_mp; /* where is it mounted */ |
0a5eb7c8 | 56 | struct hlist_node mnt_mp_list; /* list mounts with the same mountpoint */ |
c63181e6 AV |
57 | #ifdef CONFIG_FSNOTIFY |
58 | struct hlist_head mnt_fsnotify_marks; | |
59 | __u32 mnt_fsnotify_mask; | |
60 | #endif | |
15169fe7 AV |
61 | int mnt_id; /* mount identifier */ |
62 | int mnt_group_id; /* peer group identifier */ | |
863d684f | 63 | int mnt_expiry_mark; /* true if marked for expiry */ |
215752fc | 64 | struct hlist_head mnt_pins; |
aba809cf | 65 | struct path mnt_ex_mountpoint; |
7d6fec45 AV |
66 | }; |
67 | ||
f7a99c5b AV |
68 | #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */ |
69 | ||
7d6fec45 AV |
70 | static inline struct mount *real_mount(struct vfsmount *mnt) |
71 | { | |
72 | return container_of(mnt, struct mount, mnt); | |
73 | } | |
74 | ||
676da58d | 75 | static inline int mnt_has_parent(struct mount *mnt) |
b2dba1af | 76 | { |
0714a533 | 77 | return mnt != mnt->mnt_parent; |
b2dba1af | 78 | } |
c7105365 | 79 | |
f7a99c5b AV |
80 | static inline int is_mounted(struct vfsmount *mnt) |
81 | { | |
82 | /* neither detached nor internal? */ | |
260a459d | 83 | return !IS_ERR_OR_NULL(real_mount(mnt)->mnt_ns); |
f7a99c5b AV |
84 | } |
85 | ||
474279dc AV |
86 | extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *); |
87 | extern struct mount *__lookup_mnt_last(struct vfsmount *, struct dentry *); | |
0226f492 | 88 | |
48a066e7 AV |
89 | extern bool legitimize_mnt(struct vfsmount *, unsigned); |
90 | ||
80b5dce8 EB |
91 | extern void __detach_mounts(struct dentry *dentry); |
92 | ||
93 | static inline void detach_mounts(struct dentry *dentry) | |
94 | { | |
95 | if (!d_mountpoint(dentry)) | |
96 | return; | |
97 | __detach_mounts(dentry); | |
98 | } | |
99 | ||
0226f492 AV |
100 | static inline void get_mnt_ns(struct mnt_namespace *ns) |
101 | { | |
102 | atomic_inc(&ns->count); | |
103 | } | |
104 | ||
48a066e7 | 105 | extern seqlock_t mount_lock; |
719ea2fb AV |
106 | |
107 | static inline void lock_mount_hash(void) | |
108 | { | |
48a066e7 | 109 | write_seqlock(&mount_lock); |
719ea2fb AV |
110 | } |
111 | ||
112 | static inline void unlock_mount_hash(void) | |
113 | { | |
48a066e7 | 114 | write_sequnlock(&mount_lock); |
719ea2fb AV |
115 | } |
116 | ||
0226f492 | 117 | struct proc_mounts { |
6ce6e24e | 118 | struct seq_file m; |
0226f492 AV |
119 | struct mnt_namespace *ns; |
120 | struct path root; | |
121 | int (*show)(struct seq_file *, struct vfsmount *); | |
c7999c36 AV |
122 | void *cached_mount; |
123 | u64 cached_event; | |
124 | loff_t cached_index; | |
0226f492 AV |
125 | }; |
126 | ||
6ce6e24e AV |
127 | #define proc_mounts(p) (container_of((p), struct proc_mounts, m)) |
128 | ||
0226f492 | 129 | extern const struct seq_operations mounts_op; |
7af1364f EB |
130 | |
131 | extern bool __is_local_mountpoint(struct dentry *dentry); | |
132 | static inline bool is_local_mountpoint(struct dentry *dentry) | |
133 | { | |
134 | if (!d_mountpoint(dentry)) | |
135 | return false; | |
136 | ||
137 | return __is_local_mountpoint(dentry); | |
138 | } |