xref: /linux/include/uapi/linux/mount.h (revision cf79f291f985662150363b4a93d16f88f12643bc)
1e262e32dSDavid Howells #ifndef _UAPI_LINUX_MOUNT_H
2e262e32dSDavid Howells #define _UAPI_LINUX_MOUNT_H
3e262e32dSDavid Howells 
42a186721SChristian Brauner #include <linux/types.h>
52a186721SChristian Brauner 
6e262e32dSDavid Howells /*
7e262e32dSDavid Howells  * These are the fs-independent mount-flags: up to 32 flags are supported
8e262e32dSDavid Howells  *
9e262e32dSDavid Howells  * Usage of these is restricted within the kernel to core mount(2) code and
10e262e32dSDavid Howells  * callers of sys_mount() only.  Filesystems should be using the SB_*
11e262e32dSDavid Howells  * equivalent instead.
12e262e32dSDavid Howells  */
13e262e32dSDavid Howells #define MS_RDONLY	 1	/* Mount read-only */
14e262e32dSDavid Howells #define MS_NOSUID	 2	/* Ignore suid and sgid bits */
15e262e32dSDavid Howells #define MS_NODEV	 4	/* Disallow access to device special files */
16e262e32dSDavid Howells #define MS_NOEXEC	 8	/* Disallow program execution */
17e262e32dSDavid Howells #define MS_SYNCHRONOUS	16	/* Writes are synced at once */
18e262e32dSDavid Howells #define MS_REMOUNT	32	/* Alter flags of a mounted FS */
19e262e32dSDavid Howells #define MS_MANDLOCK	64	/* Allow mandatory locks on an FS */
20e262e32dSDavid Howells #define MS_DIRSYNC	128	/* Directory modifications are synchronous */
21dab741e0SMattias Nissler #define MS_NOSYMFOLLOW	256	/* Do not follow symlinks */
22e262e32dSDavid Howells #define MS_NOATIME	1024	/* Do not update access times. */
23e262e32dSDavid Howells #define MS_NODIRATIME	2048	/* Do not update directory access times */
24e262e32dSDavid Howells #define MS_BIND		4096
25e262e32dSDavid Howells #define MS_MOVE		8192
26e262e32dSDavid Howells #define MS_REC		16384
27e262e32dSDavid Howells #define MS_VERBOSE	32768	/* War is peace. Verbosity is silence.
28e262e32dSDavid Howells 				   MS_VERBOSE is deprecated. */
29e262e32dSDavid Howells #define MS_SILENT	32768
30e262e32dSDavid Howells #define MS_POSIXACL	(1<<16)	/* VFS does not apply the umask */
31e262e32dSDavid Howells #define MS_UNBINDABLE	(1<<17)	/* change to unbindable */
32e262e32dSDavid Howells #define MS_PRIVATE	(1<<18)	/* change to private */
33e262e32dSDavid Howells #define MS_SLAVE	(1<<19)	/* change to slave */
34e262e32dSDavid Howells #define MS_SHARED	(1<<20)	/* change to shared */
35e262e32dSDavid Howells #define MS_RELATIME	(1<<21)	/* Update atime relative to mtime/ctime. */
36e262e32dSDavid Howells #define MS_KERNMOUNT	(1<<22) /* this is a kern_mount call */
37e262e32dSDavid Howells #define MS_I_VERSION	(1<<23) /* Update inode I_version field */
38e262e32dSDavid Howells #define MS_STRICTATIME	(1<<24) /* Always perform atime updates */
39e262e32dSDavid Howells #define MS_LAZYTIME	(1<<25) /* Update the on-disk [acm]times lazily */
40e262e32dSDavid Howells 
41e262e32dSDavid Howells /* These sb flags are internal to the kernel */
42e262e32dSDavid Howells #define MS_SUBMOUNT     (1<<26)
43e262e32dSDavid Howells #define MS_NOREMOTELOCK	(1<<27)
44e262e32dSDavid Howells #define MS_NOSEC	(1<<28)
45e262e32dSDavid Howells #define MS_BORN		(1<<29)
46e262e32dSDavid Howells #define MS_ACTIVE	(1<<30)
47e262e32dSDavid Howells #define MS_NOUSER	(1<<31)
48e262e32dSDavid Howells 
49e262e32dSDavid Howells /*
50e262e32dSDavid Howells  * Superblock flags that can be altered by MS_REMOUNT
51e262e32dSDavid Howells  */
52e262e32dSDavid Howells #define MS_RMT_MASK	(MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION|\
53e262e32dSDavid Howells 			 MS_LAZYTIME)
54e262e32dSDavid Howells 
55e262e32dSDavid Howells /*
56e262e32dSDavid Howells  * Old magic mount flag and mask
57e262e32dSDavid Howells  */
58e262e32dSDavid Howells #define MS_MGC_VAL 0xC0ED0000
59e262e32dSDavid Howells #define MS_MGC_MSK 0xffff0000
60e262e32dSDavid Howells 
61a07b2000SAl Viro /*
62a07b2000SAl Viro  * open_tree() flags.
63a07b2000SAl Viro  */
64a07b2000SAl Viro #define OPEN_TREE_CLONE		1		/* Clone the target tree and attach the clone */
65a07b2000SAl Viro #define OPEN_TREE_CLOEXEC	O_CLOEXEC	/* Close the file on execve() */
66a07b2000SAl Viro 
672db154b3SDavid Howells /*
682db154b3SDavid Howells  * move_mount() flags.
692db154b3SDavid Howells  */
702db154b3SDavid Howells #define MOVE_MOUNT_F_SYMLINKS		0x00000001 /* Follow symlinks on from path */
712db154b3SDavid Howells #define MOVE_MOUNT_F_AUTOMOUNTS		0x00000002 /* Follow automounts on from path */
722db154b3SDavid Howells #define MOVE_MOUNT_F_EMPTY_PATH		0x00000004 /* Empty from path permitted */
732db154b3SDavid Howells #define MOVE_MOUNT_T_SYMLINKS		0x00000010 /* Follow symlinks on to path */
742db154b3SDavid Howells #define MOVE_MOUNT_T_AUTOMOUNTS		0x00000020 /* Follow automounts on to path */
752db154b3SDavid Howells #define MOVE_MOUNT_T_EMPTY_PATH		0x00000040 /* Empty to path permitted */
769ffb14efSPavel Tikhomirov #define MOVE_MOUNT_SET_GROUP		0x00000100 /* Set sharing group instead */
776ac39281SChristian Brauner #define MOVE_MOUNT_BENEATH		0x00000200 /* Mount beneath top mount */
786ac39281SChristian Brauner #define MOVE_MOUNT__MASK		0x00000377
792db154b3SDavid Howells 
8024dcb3d9SDavid Howells /*
8124dcb3d9SDavid Howells  * fsopen() flags.
8224dcb3d9SDavid Howells  */
8324dcb3d9SDavid Howells #define FSOPEN_CLOEXEC		0x00000001
8424dcb3d9SDavid Howells 
85ecdab150SDavid Howells /*
86cf3cba4aSDavid Howells  * fspick() flags.
87cf3cba4aSDavid Howells  */
88cf3cba4aSDavid Howells #define FSPICK_CLOEXEC		0x00000001
89cf3cba4aSDavid Howells #define FSPICK_SYMLINK_NOFOLLOW	0x00000002
90cf3cba4aSDavid Howells #define FSPICK_NO_AUTOMOUNT	0x00000004
91cf3cba4aSDavid Howells #define FSPICK_EMPTY_PATH	0x00000008
92cf3cba4aSDavid Howells 
93cf3cba4aSDavid Howells /*
94ecdab150SDavid Howells  * The type of fsconfig() call made.
95ecdab150SDavid Howells  */
96ecdab150SDavid Howells enum fsconfig_command {
97ecdab150SDavid Howells 	FSCONFIG_SET_FLAG	= 0,	/* Set parameter, supplying no value */
98ecdab150SDavid Howells 	FSCONFIG_SET_STRING	= 1,	/* Set parameter, supplying a string value */
99ecdab150SDavid Howells 	FSCONFIG_SET_BINARY	= 2,	/* Set parameter, supplying a binary blob value */
100ecdab150SDavid Howells 	FSCONFIG_SET_PATH	= 3,	/* Set parameter, supplying an object by path */
101ecdab150SDavid Howells 	FSCONFIG_SET_PATH_EMPTY	= 4,	/* Set parameter, supplying an object by (empty) path */
102ecdab150SDavid Howells 	FSCONFIG_SET_FD		= 5,	/* Set parameter, supplying an object by fd */
10322ed7ecdSChristian Brauner 	FSCONFIG_CMD_CREATE	= 6,	/* Create new or reuse existing superblock */
104ecdab150SDavid Howells 	FSCONFIG_CMD_RECONFIGURE = 7,	/* Invoke superblock reconfiguration */
10522ed7ecdSChristian Brauner 	FSCONFIG_CMD_CREATE_EXCL = 8,	/* Create new superblock, fail if reusing existing superblock */
106ecdab150SDavid Howells };
107ecdab150SDavid Howells 
10893766fbdSDavid Howells /*
10993766fbdSDavid Howells  * fsmount() flags.
11093766fbdSDavid Howells  */
11193766fbdSDavid Howells #define FSMOUNT_CLOEXEC		0x00000001
11293766fbdSDavid Howells 
11393766fbdSDavid Howells /*
11493766fbdSDavid Howells  * Mount attributes.
11593766fbdSDavid Howells  */
11693766fbdSDavid Howells #define MOUNT_ATTR_RDONLY	0x00000001 /* Mount read-only */
11793766fbdSDavid Howells #define MOUNT_ATTR_NOSUID	0x00000002 /* Ignore suid and sgid bits */
11893766fbdSDavid Howells #define MOUNT_ATTR_NODEV	0x00000004 /* Disallow access to device special files */
11993766fbdSDavid Howells #define MOUNT_ATTR_NOEXEC	0x00000008 /* Disallow program execution */
12093766fbdSDavid Howells #define MOUNT_ATTR__ATIME	0x00000070 /* Setting on how atime should be updated */
12193766fbdSDavid Howells #define MOUNT_ATTR_RELATIME	0x00000000 /* - Update atime relative to mtime/ctime. */
12293766fbdSDavid Howells #define MOUNT_ATTR_NOATIME	0x00000010 /* - Do not update access times. */
12393766fbdSDavid Howells #define MOUNT_ATTR_STRICTATIME	0x00000020 /* - Always perform atime updates */
12493766fbdSDavid Howells #define MOUNT_ATTR_NODIRATIME	0x00000080 /* Do not update directory access times */
1259caccd41SChristian Brauner #define MOUNT_ATTR_IDMAP	0x00100000 /* Idmap mount to @userns_fd in struct mount_attr. */
126dd8b477fSChristian Brauner #define MOUNT_ATTR_NOSYMFOLLOW	0x00200000 /* Do not follow symlinks */
12793766fbdSDavid Howells 
1282a186721SChristian Brauner /*
1292a186721SChristian Brauner  * mount_setattr()
1302a186721SChristian Brauner  */
1312a186721SChristian Brauner struct mount_attr {
1322a186721SChristian Brauner 	__u64 attr_set;
1332a186721SChristian Brauner 	__u64 attr_clr;
1342a186721SChristian Brauner 	__u64 propagation;
1352a186721SChristian Brauner 	__u64 userns_fd;
1362a186721SChristian Brauner };
1372a186721SChristian Brauner 
1382a186721SChristian Brauner /* List of all mount_attr versions. */
1392a186721SChristian Brauner #define MOUNT_ATTR_SIZE_VER0	32 /* sizeof first published struct */
1402a186721SChristian Brauner 
14146eae99eSMiklos Szeredi 
14246eae99eSMiklos Szeredi /*
14346eae99eSMiklos Szeredi  * Structure for getting mount/superblock/filesystem info with statmount(2).
14446eae99eSMiklos Szeredi  *
14546eae99eSMiklos Szeredi  * The interface is similar to statx(2): individual fields or groups can be
14646eae99eSMiklos Szeredi  * selected with the @mask argument of statmount().  Kernel will set the @mask
14746eae99eSMiklos Szeredi  * field according to the supported fields.
14846eae99eSMiklos Szeredi  *
14946eae99eSMiklos Szeredi  * If string fields are selected, then the caller needs to pass a buffer that
15046eae99eSMiklos Szeredi  * has space after the fixed part of the structure.  Nul terminated strings are
15146eae99eSMiklos Szeredi  * copied there and offsets relative to @str are stored in the relevant fields.
15246eae99eSMiklos Szeredi  * If the buffer is too small, then EOVERFLOW is returned.  The actually used
15346eae99eSMiklos Szeredi  * size is returned in @size.
15446eae99eSMiklos Szeredi  */
15546eae99eSMiklos Szeredi struct statmount {
15646eae99eSMiklos Szeredi 	__u32 size;		/* Total size, including strings */
15746eae99eSMiklos Szeredi 	__u32 __spare1;
15846eae99eSMiklos Szeredi 	__u64 mask;		/* What results were written */
15946eae99eSMiklos Szeredi 	__u32 sb_dev_major;	/* Device ID */
16046eae99eSMiklos Szeredi 	__u32 sb_dev_minor;
16146eae99eSMiklos Szeredi 	__u64 sb_magic;		/* ..._SUPER_MAGIC */
16246eae99eSMiklos Szeredi 	__u32 sb_flags;		/* SB_{RDONLY,SYNCHRONOUS,DIRSYNC,LAZYTIME} */
16346eae99eSMiklos Szeredi 	__u32 fs_type;		/* [str] Filesystem type */
16446eae99eSMiklos Szeredi 	__u64 mnt_id;		/* Unique ID of mount */
16546eae99eSMiklos Szeredi 	__u64 mnt_parent_id;	/* Unique ID of parent (for root == mnt_id) */
16646eae99eSMiklos Szeredi 	__u32 mnt_id_old;	/* Reused IDs used in proc/.../mountinfo */
16746eae99eSMiklos Szeredi 	__u32 mnt_parent_id_old;
16846eae99eSMiklos Szeredi 	__u64 mnt_attr;		/* MOUNT_ATTR_... */
16946eae99eSMiklos Szeredi 	__u64 mnt_propagation;	/* MS_{SHARED,SLAVE,PRIVATE,UNBINDABLE} */
17046eae99eSMiklos Szeredi 	__u64 mnt_peer_group;	/* ID of shared peer group */
17146eae99eSMiklos Szeredi 	__u64 mnt_master;	/* Mount receives propagation from this ID */
17246eae99eSMiklos Szeredi 	__u64 propagate_from;	/* Propagation from in current namespace */
17346eae99eSMiklos Szeredi 	__u32 mnt_root;		/* [str] Root of mount relative to root of fs */
17446eae99eSMiklos Szeredi 	__u32 mnt_point;	/* [str] Mountpoint relative to current root */
17546eae99eSMiklos Szeredi 	__u64 __spare2[50];
17646eae99eSMiklos Szeredi 	char str[];		/* Variable size part containing strings */
17746eae99eSMiklos Szeredi };
17846eae99eSMiklos Szeredi 
179b4c2bea8SMiklos Szeredi /*
180b4c2bea8SMiklos Szeredi  * Structure for passing mount ID and miscellaneous parameters to statmount(2)
181b4c2bea8SMiklos Szeredi  * and listmount(2).
182b4c2bea8SMiklos Szeredi  *
183b4c2bea8SMiklos Szeredi  * For statmount(2) @param represents the request mask.
184b4c2bea8SMiklos Szeredi  * For listmount(2) @param represents the last listed mount id (or zero).
185b4c2bea8SMiklos Szeredi  */
18646eae99eSMiklos Szeredi struct mnt_id_req {
187*35e27a57SChristian Brauner 	__u32 size;
188*35e27a57SChristian Brauner 	__u32 spare;
18946eae99eSMiklos Szeredi 	__u64 mnt_id;
190b4c2bea8SMiklos Szeredi 	__u64 param;
19146eae99eSMiklos Szeredi };
19246eae99eSMiklos Szeredi 
193*35e27a57SChristian Brauner /* List of all mnt_id_req versions. */
194*35e27a57SChristian Brauner #define MNT_ID_REQ_SIZE_VER0	24 /* sizeof first published struct */
195*35e27a57SChristian Brauner 
19646eae99eSMiklos Szeredi /*
19746eae99eSMiklos Szeredi  * @mask bits for statmount(2)
19846eae99eSMiklos Szeredi  */
19946eae99eSMiklos Szeredi #define STATMOUNT_SB_BASIC		0x00000001U     /* Want/got sb_... */
20046eae99eSMiklos Szeredi #define STATMOUNT_MNT_BASIC		0x00000002U	/* Want/got mnt_... */
20146eae99eSMiklos Szeredi #define STATMOUNT_PROPAGATE_FROM	0x00000004U	/* Want/got propagate_from */
20246eae99eSMiklos Szeredi #define STATMOUNT_MNT_ROOT		0x00000008U	/* Want/got mnt_root  */
20346eae99eSMiklos Szeredi #define STATMOUNT_MNT_POINT		0x00000010U	/* Want/got mnt_point */
20446eae99eSMiklos Szeredi #define STATMOUNT_FS_TYPE		0x00000020U	/* Want/got fs_type */
20546eae99eSMiklos Szeredi 
206b4c2bea8SMiklos Szeredi /*
207b4c2bea8SMiklos Szeredi  * Special @mnt_id values that can be passed to listmount
208b4c2bea8SMiklos Szeredi  */
209b4c2bea8SMiklos Szeredi #define LSMT_ROOT		0xffffffffffffffff	/* root mount */
210b4c2bea8SMiklos Szeredi 
211e262e32dSDavid Howells #endif /* _UAPI_LINUX_MOUNT_H */
212