xref: /openbmc/linux/fs/mount.h (revision 48a066e7)
1b2dba1afSAl Viro #include <linux/mount.h>
20226f492SAl Viro #include <linux/seq_file.h>
30226f492SAl Viro #include <linux/poll.h>
40226f492SAl Viro 
50226f492SAl Viro struct mnt_namespace {
60226f492SAl Viro 	atomic_t		count;
798f842e6SEric W. Biederman 	unsigned int		proc_inum;
8be08d6d2SAl Viro 	struct mount *	root;
90226f492SAl Viro 	struct list_head	list;
10771b1371SEric W. Biederman 	struct user_namespace	*user_ns;
118823c079SEric W. Biederman 	u64			seq;	/* Sequence number to prevent loops */
120226f492SAl Viro 	wait_queue_head_t poll;
130226f492SAl Viro 	int event;
140226f492SAl Viro };
15b2dba1afSAl Viro 
1668e8a9feSAl Viro struct mnt_pcp {
1768e8a9feSAl Viro 	int mnt_count;
1868e8a9feSAl Viro 	int mnt_writers;
1968e8a9feSAl Viro };
2068e8a9feSAl Viro 
2184d17192SAl Viro struct mountpoint {
2284d17192SAl Viro 	struct list_head m_hash;
2384d17192SAl Viro 	struct dentry *m_dentry;
2484d17192SAl Viro 	int m_count;
2584d17192SAl Viro };
2684d17192SAl Viro 
277d6fec45SAl Viro struct mount {
281b8e5564SAl Viro 	struct list_head mnt_hash;
290714a533SAl Viro 	struct mount *mnt_parent;
30a73324daSAl Viro 	struct dentry *mnt_mountpoint;
317d6fec45SAl Viro 	struct vfsmount mnt;
3248a066e7SAl Viro 	struct rcu_head mnt_rcu;
3368e8a9feSAl Viro #ifdef CONFIG_SMP
3468e8a9feSAl Viro 	struct mnt_pcp __percpu *mnt_pcp;
3568e8a9feSAl Viro #else
3668e8a9feSAl Viro 	int mnt_count;
3768e8a9feSAl Viro 	int mnt_writers;
3868e8a9feSAl Viro #endif
396b41d536SAl Viro 	struct list_head mnt_mounts;	/* list of children, anchored here */
406b41d536SAl Viro 	struct list_head mnt_child;	/* and going through their mnt_child */
4139f7c4dbSMiklos Szeredi 	struct list_head mnt_instance;	/* mount instance on sb->s_mounts */
4252ba1621SAl Viro 	const char *mnt_devname;	/* Name of device e.g. /dev/dsk/hda1 */
431a4eeaf2SAl Viro 	struct list_head mnt_list;
446776db3dSAl Viro 	struct list_head mnt_expire;	/* link in fs-specific expiry list */
456776db3dSAl Viro 	struct list_head mnt_share;	/* circular list of shared mounts */
466776db3dSAl Viro 	struct list_head mnt_slave_list;/* list of slave mounts */
476776db3dSAl Viro 	struct list_head mnt_slave;	/* slave list entry */
4832301920SAl Viro 	struct mount *mnt_master;	/* slave is on master->mnt_slave_list */
49143c8c91SAl Viro 	struct mnt_namespace *mnt_ns;	/* containing namespace */
5084d17192SAl Viro 	struct mountpoint *mnt_mp;	/* where is it mounted */
51c63181e6SAl Viro #ifdef CONFIG_FSNOTIFY
52c63181e6SAl Viro 	struct hlist_head mnt_fsnotify_marks;
53c63181e6SAl Viro 	__u32 mnt_fsnotify_mask;
54c63181e6SAl Viro #endif
5515169fe7SAl Viro 	int mnt_id;			/* mount identifier */
5615169fe7SAl Viro 	int mnt_group_id;		/* peer group identifier */
57863d684fSAl Viro 	int mnt_expiry_mark;		/* true if marked for expiry */
58863d684fSAl Viro 	int mnt_pinned;
59aba809cfSAl Viro 	struct path mnt_ex_mountpoint;
607d6fec45SAl Viro };
617d6fec45SAl Viro 
62f7a99c5bSAl Viro #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
63f7a99c5bSAl Viro 
647d6fec45SAl Viro static inline struct mount *real_mount(struct vfsmount *mnt)
657d6fec45SAl Viro {
667d6fec45SAl Viro 	return container_of(mnt, struct mount, mnt);
677d6fec45SAl Viro }
687d6fec45SAl Viro 
69676da58dSAl Viro static inline int mnt_has_parent(struct mount *mnt)
70b2dba1afSAl Viro {
710714a533SAl Viro 	return mnt != mnt->mnt_parent;
72b2dba1afSAl Viro }
73c7105365SAl Viro 
74f7a99c5bSAl Viro static inline int is_mounted(struct vfsmount *mnt)
75f7a99c5bSAl Viro {
76f7a99c5bSAl Viro 	/* neither detached nor internal? */
77f7a99c5bSAl Viro 	return !IS_ERR_OR_NULL(real_mount(mnt));
78f7a99c5bSAl Viro }
79f7a99c5bSAl Viro 
80474279dcSAl Viro extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *);
81474279dcSAl Viro extern struct mount *__lookup_mnt_last(struct vfsmount *, struct dentry *);
820226f492SAl Viro 
8348a066e7SAl Viro extern bool legitimize_mnt(struct vfsmount *, unsigned);
8448a066e7SAl Viro 
850226f492SAl Viro static inline void get_mnt_ns(struct mnt_namespace *ns)
860226f492SAl Viro {
870226f492SAl Viro 	atomic_inc(&ns->count);
880226f492SAl Viro }
890226f492SAl Viro 
9048a066e7SAl Viro extern seqlock_t mount_lock;
91719ea2fbSAl Viro 
92719ea2fbSAl Viro static inline void lock_mount_hash(void)
93719ea2fbSAl Viro {
9448a066e7SAl Viro 	write_seqlock(&mount_lock);
95719ea2fbSAl Viro }
96719ea2fbSAl Viro 
97719ea2fbSAl Viro static inline void unlock_mount_hash(void)
98719ea2fbSAl Viro {
9948a066e7SAl Viro 	write_sequnlock(&mount_lock);
100719ea2fbSAl Viro }
101719ea2fbSAl Viro 
1020226f492SAl Viro struct proc_mounts {
1036ce6e24eSAl Viro 	struct seq_file m;
1040226f492SAl Viro 	struct mnt_namespace *ns;
1050226f492SAl Viro 	struct path root;
1060226f492SAl Viro 	int (*show)(struct seq_file *, struct vfsmount *);
1070226f492SAl Viro };
1080226f492SAl Viro 
1096ce6e24eSAl Viro #define proc_mounts(p) (container_of((p), struct proc_mounts, m))
1106ce6e24eSAl Viro 
1110226f492SAl Viro extern const struct seq_operations mounts_op;
112