xref: /openbmc/linux/include/linux/mount.h (revision 73648e6f)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Definitions for mount interface. This describes the in the kernel build
51da177e4SLinus Torvalds  * linkedlist with mounted filesystems.
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  * Author:  Marco van Wieringen <mvw@planets.elm.net>
81da177e4SLinus Torvalds  *
91da177e4SLinus Torvalds  */
101da177e4SLinus Torvalds #ifndef _LINUX_MOUNT_H
111da177e4SLinus Torvalds #define _LINUX_MOUNT_H
121da177e4SLinus Torvalds 
13d53d9f16SAndrew Morton #include <linux/types.h>
1459df85d5SAl Viro #include <asm/barrier.h>
151da177e4SLinus Torvalds 
16726c3342SDavid Howells struct super_block;
17726c3342SDavid Howells struct dentry;
1859df85d5SAl Viro struct user_namespace;
19256c8aedSChristian Brauner struct mnt_idmap;
2059df85d5SAl Viro struct file_system_type;
218f291889SAl Viro struct fs_context;
2259df85d5SAl Viro struct file;
2359df85d5SAl Viro struct path;
24726c3342SDavid Howells 
2507b20889SRam Pai #define MNT_NOSUID	0x01
2607b20889SRam Pai #define MNT_NODEV	0x02
2707b20889SRam Pai #define MNT_NOEXEC	0x04
28fc33a7bbSChristoph Hellwig #define MNT_NOATIME	0x08
29fc33a7bbSChristoph Hellwig #define MNT_NODIRATIME	0x10
3047ae32d6SValerie Henson #define MNT_RELATIME	0x20
312e4b7fcdSDave Hansen #define MNT_READONLY	0x40	/* does the user want this to be r/o? */
32dab741e0SMattias Nissler #define MNT_NOSYMFOLLOW	0x80
33bf066c7dSMiklos Szeredi 
345528f911STrond Myklebust #define MNT_SHRINKABLE	0x100
35d3ef3d73Snpiggin@suse.de #define MNT_WRITE_HOLD	0x200
365528f911STrond Myklebust 
37fc33a7bbSChristoph Hellwig #define MNT_SHARED	0x1000	/* if the vfsmount is a shared mount */
38fc33a7bbSChristoph Hellwig #define MNT_UNBINDABLE	0x2000	/* if the vfsmount is a unbindable mount */
39495d6c9cSValerie Aurora /*
40495d6c9cSValerie Aurora  * MNT_SHARED_MASK is the set of flags that should be cleared when a
41495d6c9cSValerie Aurora  * mount becomes shared.  Currently, this is only the flag that says a
42495d6c9cSValerie Aurora  * mount cannot be bind mounted, since this is how we create a mount
43495d6c9cSValerie Aurora  * that shares events with another mount.  If you add a new MNT_*
44495d6c9cSValerie Aurora  * flag, consider how it interacts with shared mounts.
45495d6c9cSValerie Aurora  */
46495d6c9cSValerie Aurora #define MNT_SHARED_MASK	(MNT_UNBINDABLE)
47a6138db8SEric W. Biederman #define MNT_USER_SETTABLE_MASK  (MNT_NOSUID | MNT_NODEV | MNT_NOEXEC \
48a6138db8SEric W. Biederman 				 | MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME \
49dab741e0SMattias Nissler 				 | MNT_READONLY | MNT_NOSYMFOLLOW)
509566d674SEric W. Biederman #define MNT_ATIME_MASK (MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME )
51495d6c9cSValerie Aurora 
52f2ebb3a9SAl Viro #define MNT_INTERNAL_FLAGS (MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | \
539f6c61f9SMiklos Szeredi 			    MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED | \
549f6c61f9SMiklos Szeredi 			    MNT_CURSOR)
551da177e4SLinus Torvalds 
568089352aSAl Viro #define MNT_INTERNAL	0x4000
571da177e4SLinus Torvalds 
589566d674SEric W. Biederman #define MNT_LOCK_ATIME		0x040000
599566d674SEric W. Biederman #define MNT_LOCK_NOEXEC		0x080000
609566d674SEric W. Biederman #define MNT_LOCK_NOSUID		0x100000
619566d674SEric W. Biederman #define MNT_LOCK_NODEV		0x200000
6290563b19SEric W. Biederman #define MNT_LOCK_READONLY	0x400000
635ff9d8a6SEric W. Biederman #define MNT_LOCKED		0x800000
6448a066e7SAl Viro #define MNT_DOOMED		0x1000000
6548a066e7SAl Viro #define MNT_SYNC_UMOUNT		0x2000000
66f2ebb3a9SAl Viro #define MNT_MARKED		0x4000000
67590ce4bcSEric W. Biederman #define MNT_UMOUNT		0x8000000
689f6c61f9SMiklos Szeredi #define MNT_CURSOR		0x10000000
6990563b19SEric W. Biederman 
7007b20889SRam Pai struct vfsmount {
711da177e4SLinus Torvalds 	struct dentry *mnt_root;	/* root of the mounted tree */
721da177e4SLinus Torvalds 	struct super_block *mnt_sb;	/* pointer to superblock */
731da177e4SLinus Torvalds 	int mnt_flags;
74256c8aedSChristian Brauner 	struct mnt_idmap *mnt_idmap;
753859a271SKees Cook } __randomize_layout;
761da177e4SLinus Torvalds 
mnt_idmap(const struct vfsmount * mnt)77256c8aedSChristian Brauner static inline struct mnt_idmap *mnt_idmap(const struct vfsmount *mnt)
78a6435940SChristian Brauner {
799caccd41SChristian Brauner 	/* Pairs with smp_store_release() in do_idmap_mount(). */
80256c8aedSChristian Brauner 	return smp_load_acquire(&mnt->mnt_idmap);
81a6435940SChristian Brauner }
82a6435940SChristian Brauner 
838366025eSDave Hansen extern int mnt_want_write(struct vfsmount *mnt);
8496029c4eSnpiggin@suse.de extern int mnt_want_write_file(struct file *file);
858366025eSDave Hansen extern void mnt_drop_write(struct vfsmount *mnt);
862a79f17eSAl Viro extern void mnt_drop_write_file(struct file *file);
87b3e19d92SNick Piggin extern void mntput(struct vfsmount *mnt);
88b3e19d92SNick Piggin extern struct vfsmount *mntget(struct vfsmount *mnt);
89da27f796SRik van Riel extern void mnt_make_shortterm(struct vfsmount *mnt);
90ca71cf71SAl Viro extern struct vfsmount *mnt_clone_internal(const struct path *path);
9143f5e655SDavid Howells extern bool __mnt_is_readonly(struct vfsmount *mnt);
92380cf5baSAndy Lutomirski extern bool mnt_may_suid(struct vfsmount *mnt);
931da177e4SLinus Torvalds 
94ca71cf71SAl Viro extern struct vfsmount *clone_private_mount(const struct path *path);
959419a319SAl Viro extern int __mnt_want_write(struct vfsmount *);
969419a319SAl Viro extern void __mnt_drop_write(struct vfsmount *);
97c771d683SMiklos Szeredi 
988f291889SAl Viro extern struct vfsmount *fc_mount(struct fs_context *fc);
998f291889SAl Viro extern struct vfsmount *vfs_create_mount(struct fs_context *fc);
100bb4a58bfSTrond Myklebust extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
101bb4a58bfSTrond Myklebust 				      int flags, const char *name,
102bb4a58bfSTrond Myklebust 				      void *data);
10393faccbbSEric W. Biederman extern struct vfsmount *vfs_submount(const struct dentry *mountpoint,
10493faccbbSEric W. Biederman 				     struct file_system_type *type,
10593faccbbSEric W. Biederman 				     const char *name, void *data);
106bb4a58bfSTrond Myklebust 
107ea5b778aSDavid Howells extern void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list);
1081da177e4SLinus Torvalds extern void mark_mounts_for_expiry(struct list_head *mounts);
1091da177e4SLinus Torvalds 
110e6e20a7aSDan Ehrenberg extern bool path_is_mountpoint(const struct path *path);
111c6609c0aSIan Kent 
112c6609c0aSIan Kent extern bool our_mnt(struct vfsmount *mnt);
11370f8d9c5SAl Viro 
11470f8d9c5SAl Viro extern struct vfsmount *kern_mount(struct file_system_type *);
11570f8d9c5SAl Viro extern void kern_unmount(struct vfsmount *mnt);
11670f8d9c5SAl Viro extern int may_umount_tree(struct vfsmount *);
11770f8d9c5SAl Viro extern int may_umount(struct vfsmount *);
11870f8d9c5SAl Viro extern long do_mount(const char *, const char __user *,
11970f8d9c5SAl Viro 		     const char *, unsigned long, void *);
12070f8d9c5SAl Viro extern struct vfsmount *collect_mounts(const struct path *);
12170f8d9c5SAl Viro extern void drop_collected_mounts(struct vfsmount *);
12270f8d9c5SAl Viro extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
12370f8d9c5SAl Viro 			  struct vfsmount *);
12470f8d9c5SAl Viro extern void kern_unmount_array(struct vfsmount *mnt[], unsigned int num);
125df820f8dSMiklos Szeredi 
126df820f8dSMiklos Szeredi extern int cifs_root_data(char **dev, char **opts);
127*73648e6fSArnd Bergmann 
128*73648e6fSArnd Bergmann #endif /* _LINUX_MOUNT_H */
1291da177e4SLinus Torvalds