Blame view

fs/mount.h 3.95 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
b2dba1af3   Al Viro   vfs: new internal...
2
  #include <linux/mount.h>
0226f4923   Al Viro   vfs: take /proc/*...
3
4
  #include <linux/seq_file.h>
  #include <linux/poll.h>
435d5f4bb   Al Viro   common object emb...
5
  #include <linux/ns_common.h>
87b95ce09   Al Viro   switch the IO-tri...
6
  #include <linux/fs_pin.h>
0226f4923   Al Viro   vfs: take /proc/*...
7
8
9
  
  struct mnt_namespace {
  	atomic_t		count;
435d5f4bb   Al Viro   common object emb...
10
  	struct ns_common	ns;
be08d6d26   Al Viro   switch mnt_namesp...
11
  	struct mount *	root;
0226f4923   Al Viro   vfs: take /proc/*...
12
  	struct list_head	list;
771b13716   Eric W. Biederman   vfs: Add a user n...
13
  	struct user_namespace	*user_ns;
537f7ccb3   Eric W. Biederman   mntns: Add a limi...
14
  	struct ucounts		*ucounts;
8823c079b   Eric W. Biederman   vfs: Add setns su...
15
  	u64			seq;	/* Sequence number to prevent loops */
0226f4923   Al Viro   vfs: take /proc/*...
16
  	wait_queue_head_t poll;
c7999c362   Al Viro   reduce m_start() ...
17
  	u64 event;
d29216842   Eric W. Biederman   mnt: Add a per mo...
18
19
  	unsigned int		mounts; /* # of mounts in the namespace */
  	unsigned int		pending_mounts;
3859a271a   Kees Cook   randstruct: Mark ...
20
  } __randomize_layout;
b2dba1af3   Al Viro   vfs: new internal...
21

68e8a9fea   Al Viro   vfs: all counters...
22
23
24
25
  struct mnt_pcp {
  	int mnt_count;
  	int mnt_writers;
  };
84d17192d   Al Viro   get rid of full-h...
26
  struct mountpoint {
0818bf27c   Al Viro   resizable namespa...
27
  	struct hlist_node m_hash;
84d17192d   Al Viro   get rid of full-h...
28
  	struct dentry *m_dentry;
0a5eb7c81   Eric W. Biederman   vfs: Keep a list ...
29
  	struct hlist_head m_list;
84d17192d   Al Viro   get rid of full-h...
30
31
  	int m_count;
  };
7d6fec45a   Al Viro   vfs: start hiding...
32
  struct mount {
38129a13e   Al Viro   switch mnt_hash t...
33
  	struct hlist_node mnt_hash;
0714a5338   Al Viro   vfs: now it can b...
34
  	struct mount *mnt_parent;
a73324da7   Al Viro   vfs: move mnt_mou...
35
  	struct dentry *mnt_mountpoint;
7d6fec45a   Al Viro   vfs: start hiding...
36
  	struct vfsmount mnt;
9ea459e11   Al Viro   delayed mntput
37
38
39
40
  	union {
  		struct rcu_head mnt_rcu;
  		struct llist_node mnt_llist;
  	};
68e8a9fea   Al Viro   vfs: all counters...
41
42
  #ifdef CONFIG_SMP
  	struct mnt_pcp __percpu *mnt_pcp;
68e8a9fea   Al Viro   vfs: all counters...
43
44
45
46
  #else
  	int mnt_count;
  	int mnt_writers;
  #endif
6b41d536f   Al Viro   vfs: take mnt_chi...
47
48
  	struct list_head mnt_mounts;	/* list of children, anchored here */
  	struct list_head mnt_child;	/* and going through their mnt_child */
39f7c4db1   Miklos Szeredi   vfs: keep list of...
49
  	struct list_head mnt_instance;	/* mount instance on sb->s_mounts */
52ba1621d   Al Viro   vfs: move mnt_dev...
50
  	const char *mnt_devname;	/* Name of device e.g. /dev/dsk/hda1 */
1a4eeaf2a   Al Viro   vfs: move mnt_lis...
51
  	struct list_head mnt_list;
6776db3d3   Al Viro   vfs: take mnt_sha...
52
53
54
55
  	struct list_head mnt_expire;	/* link in fs-specific expiry list */
  	struct list_head mnt_share;	/* circular list of shared mounts */
  	struct list_head mnt_slave_list;/* list of slave mounts */
  	struct list_head mnt_slave;	/* slave list entry */
32301920f   Al Viro   vfs: and now we c...
56
  	struct mount *mnt_master;	/* slave is on master->mnt_slave_list */
143c8c91c   Al Viro   vfs: mnt_ns moved...
57
  	struct mnt_namespace *mnt_ns;	/* containing namespace */
84d17192d   Al Viro   get rid of full-h...
58
  	struct mountpoint *mnt_mp;	/* where is it mounted */
56cbb429d   Al Viro   switch the remnan...
59
60
61
62
  	union {
  		struct hlist_node mnt_mp_list;	/* list mounts with the same mountpoint */
  		struct hlist_node mnt_umount;
  	};
99b19d164   Eric W. Biederman   mnt: In propgate_...
63
  	struct list_head mnt_umounting; /* list entry for umount propagation */
c63181e6b   Al Viro   vfs: move fsnotif...
64
  #ifdef CONFIG_FSNOTIFY
08991e83b   Jan Kara   fsnotify: Free fs...
65
  	struct fsnotify_mark_connector __rcu *mnt_fsnotify_marks;
c63181e6b   Al Viro   vfs: move fsnotif...
66
67
  	__u32 mnt_fsnotify_mask;
  #endif
15169fe78   Al Viro   vfs: mnt_id/mnt_g...
68
69
  	int mnt_id;			/* mount identifier */
  	int mnt_group_id;		/* peer group identifier */
863d684f9   Al Viro   vfs: move the res...
70
  	int mnt_expiry_mark;		/* true if marked for expiry */
215752fce   Al Viro   acct: get rid of ...
71
  	struct hlist_head mnt_pins;
56cbb429d   Al Viro   switch the remnan...
72
  	struct hlist_head mnt_stuck_children;
3859a271a   Kees Cook   randstruct: Mark ...
73
  } __randomize_layout;
7d6fec45a   Al Viro   vfs: start hiding...
74

f7a99c5b7   Al Viro   get rid of ->mnt_...
75
  #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
7d6fec45a   Al Viro   vfs: start hiding...
76
77
78
79
  static inline struct mount *real_mount(struct vfsmount *mnt)
  {
  	return container_of(mnt, struct mount, mnt);
  }
676da58df   Al Viro   vfs: spread struc...
80
  static inline int mnt_has_parent(struct mount *mnt)
b2dba1af3   Al Viro   vfs: new internal...
81
  {
0714a5338   Al Viro   vfs: now it can b...
82
  	return mnt != mnt->mnt_parent;
b2dba1af3   Al Viro   vfs: new internal...
83
  }
c71053659   Al Viro   vfs: spread struc...
84

f7a99c5b7   Al Viro   get rid of ->mnt_...
85
86
87
  static inline int is_mounted(struct vfsmount *mnt)
  {
  	/* neither detached nor internal? */
260a459d2   Eric W. Biederman   vfs: Is mounted s...
88
  	return !IS_ERR_OR_NULL(real_mount(mnt)->mnt_ns);
f7a99c5b7   Al Viro   get rid of ->mnt_...
89
  }
474279dc0   Al Viro   split __lookup_mn...
90
  extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *);
0226f4923   Al Viro   vfs: take /proc/*...
91

294d71ff2   Al Viro   new helper: __leg...
92
  extern int __legitimize_mnt(struct vfsmount *, unsigned);
48a066e72   Al Viro   RCU'd vfsmounts
93
  extern bool legitimize_mnt(struct vfsmount *, unsigned);
c6609c0a1   Ian Kent   vfs: add path_is_...
94
95
96
97
98
  static inline bool __path_is_mountpoint(const struct path *path)
  {
  	struct mount *m = __lookup_mnt(path->mnt, path->dentry);
  	return m && likely(!(m->mnt.mnt_flags & MNT_SYNC_UMOUNT));
  }
80b5dce8c   Eric W. Biederman   vfs: Add a functi...
99
100
101
102
103
104
105
106
  extern void __detach_mounts(struct dentry *dentry);
  
  static inline void detach_mounts(struct dentry *dentry)
  {
  	if (!d_mountpoint(dentry))
  		return;
  	__detach_mounts(dentry);
  }
0226f4923   Al Viro   vfs: take /proc/*...
107
108
109
110
  static inline void get_mnt_ns(struct mnt_namespace *ns)
  {
  	atomic_inc(&ns->count);
  }
48a066e72   Al Viro   RCU'd vfsmounts
111
  extern seqlock_t mount_lock;
719ea2fbb   Al Viro   new helpers: lock...
112
113
114
  
  static inline void lock_mount_hash(void)
  {
48a066e72   Al Viro   RCU'd vfsmounts
115
  	write_seqlock(&mount_lock);
719ea2fbb   Al Viro   new helpers: lock...
116
117
118
119
  }
  
  static inline void unlock_mount_hash(void)
  {
48a066e72   Al Viro   RCU'd vfsmounts
120
  	write_sequnlock(&mount_lock);
719ea2fbb   Al Viro   new helpers: lock...
121
  }
0226f4923   Al Viro   vfs: take /proc/*...
122
  struct proc_mounts {
0226f4923   Al Viro   vfs: take /proc/*...
123
124
125
  	struct mnt_namespace *ns;
  	struct path root;
  	int (*show)(struct seq_file *, struct vfsmount *);
c7999c362   Al Viro   reduce m_start() ...
126
127
128
  	void *cached_mount;
  	u64 cached_event;
  	loff_t cached_index;
0226f4923   Al Viro   vfs: take /proc/*...
129
130
131
  };
  
  extern const struct seq_operations mounts_op;
7af1364ff   Eric W. Biederman   vfs: Don't allow ...
132
133
134
135
136
137
138
139
140
  
  extern bool __is_local_mountpoint(struct dentry *dentry);
  static inline bool is_local_mountpoint(struct dentry *dentry)
  {
  	if (!d_mountpoint(dentry))
  		return false;
  
  	return __is_local_mountpoint(dentry);
  }
74e831221   Al Viro   saner handling of...
141
142
143
144
145
  
  static inline bool is_anon_ns(struct mnt_namespace *ns)
  {
  	return ns->seq == 0;
  }