Blame view

fs/mount.h 3.85 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 */
0a5eb7c81   Eric W. Biederman   vfs: Keep a list ...
59
  	struct hlist_node mnt_mp_list;	/* list mounts with the same mountpoint */
99b19d164   Eric W. Biederman   mnt: In propgate_...
60
  	struct list_head mnt_umounting; /* list entry for umount propagation */
c63181e6b   Al Viro   vfs: move fsnotif...
61
  #ifdef CONFIG_FSNOTIFY
08991e83b   Jan Kara   fsnotify: Free fs...
62
  	struct fsnotify_mark_connector __rcu *mnt_fsnotify_marks;
c63181e6b   Al Viro   vfs: move fsnotif...
63
64
  	__u32 mnt_fsnotify_mask;
  #endif
15169fe78   Al Viro   vfs: mnt_id/mnt_g...
65
66
  	int mnt_id;			/* mount identifier */
  	int mnt_group_id;		/* peer group identifier */
863d684f9   Al Viro   vfs: move the res...
67
  	int mnt_expiry_mark;		/* true if marked for expiry */
215752fce   Al Viro   acct: get rid of ...
68
  	struct hlist_head mnt_pins;
87b95ce09   Al Viro   switch the IO-tri...
69
70
  	struct fs_pin mnt_umount;
  	struct dentry *mnt_ex_mountpoint;
3859a271a   Kees Cook   randstruct: Mark ...
71
  } __randomize_layout;
7d6fec45a   Al Viro   vfs: start hiding...
72

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

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

294d71ff2   Al Viro   new helper: __leg...
90
  extern int __legitimize_mnt(struct vfsmount *, unsigned);
48a066e72   Al Viro   RCU'd vfsmounts
91
  extern bool legitimize_mnt(struct vfsmount *, unsigned);
c6609c0a1   Ian Kent   vfs: add path_is_...
92
93
94
95
96
  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...
97
98
99
100
101
102
103
104
  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/*...
105
106
107
108
  static inline void get_mnt_ns(struct mnt_namespace *ns)
  {
  	atomic_inc(&ns->count);
  }
48a066e72   Al Viro   RCU'd vfsmounts
109
  extern seqlock_t mount_lock;
719ea2fbb   Al Viro   new helpers: lock...
110
111
112
  
  static inline void lock_mount_hash(void)
  {
48a066e72   Al Viro   RCU'd vfsmounts
113
  	write_seqlock(&mount_lock);
719ea2fbb   Al Viro   new helpers: lock...
114
115
116
117
  }
  
  static inline void unlock_mount_hash(void)
  {
48a066e72   Al Viro   RCU'd vfsmounts
118
  	write_sequnlock(&mount_lock);
719ea2fbb   Al Viro   new helpers: lock...
119
  }
0226f4923   Al Viro   vfs: take /proc/*...
120
  struct proc_mounts {
0226f4923   Al Viro   vfs: take /proc/*...
121
122
123
  	struct mnt_namespace *ns;
  	struct path root;
  	int (*show)(struct seq_file *, struct vfsmount *);
c7999c362   Al Viro   reduce m_start() ...
124
125
126
  	void *cached_mount;
  	u64 cached_event;
  	loff_t cached_index;
0226f4923   Al Viro   vfs: take /proc/*...
127
128
129
  };
  
  extern const struct seq_operations mounts_op;
7af1364ff   Eric W. Biederman   vfs: Don't allow ...
130
131
132
133
134
135
136
137
138
  
  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);
  }