xref: /OK3568_Linux_fs/kernel/include/uapi/linux/openat2.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun #ifndef _UAPI_LINUX_OPENAT2_H
3*4882a593Smuzhiyun #define _UAPI_LINUX_OPENAT2_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/types.h>
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun /*
8*4882a593Smuzhiyun  * Arguments for how openat2(2) should open the target path. If only @flags and
9*4882a593Smuzhiyun  * @mode are non-zero, then openat2(2) operates very similarly to openat(2).
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * However, unlike openat(2), unknown or invalid bits in @flags result in
12*4882a593Smuzhiyun  * -EINVAL rather than being silently ignored. @mode must be zero unless one of
13*4882a593Smuzhiyun  * {O_CREAT, O_TMPFILE} are set.
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * @flags: O_* flags.
16*4882a593Smuzhiyun  * @mode: O_CREAT/O_TMPFILE file mode.
17*4882a593Smuzhiyun  * @resolve: RESOLVE_* flags.
18*4882a593Smuzhiyun  */
19*4882a593Smuzhiyun struct open_how {
20*4882a593Smuzhiyun 	__u64 flags;
21*4882a593Smuzhiyun 	__u64 mode;
22*4882a593Smuzhiyun 	__u64 resolve;
23*4882a593Smuzhiyun };
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /* how->resolve flags for openat2(2). */
26*4882a593Smuzhiyun #define RESOLVE_NO_XDEV		0x01 /* Block mount-point crossings
27*4882a593Smuzhiyun 					(includes bind-mounts). */
28*4882a593Smuzhiyun #define RESOLVE_NO_MAGICLINKS	0x02 /* Block traversal through procfs-style
29*4882a593Smuzhiyun 					"magic-links". */
30*4882a593Smuzhiyun #define RESOLVE_NO_SYMLINKS	0x04 /* Block traversal through all symlinks
31*4882a593Smuzhiyun 					(implies OEXT_NO_MAGICLINKS) */
32*4882a593Smuzhiyun #define RESOLVE_BENEATH		0x08 /* Block "lexical" trickery like
33*4882a593Smuzhiyun 					"..", symlinks, and absolute
34*4882a593Smuzhiyun 					paths which escape the dirfd. */
35*4882a593Smuzhiyun #define RESOLVE_IN_ROOT		0x10 /* Make all jumps to "/" and ".."
36*4882a593Smuzhiyun 					be scoped inside the dirfd
37*4882a593Smuzhiyun 					(similar to chroot(2)). */
38*4882a593Smuzhiyun #define RESOLVE_CACHED		0x20 /* Only complete if resolution can be
39*4882a593Smuzhiyun 					completed through cached lookup. May
40*4882a593Smuzhiyun 					return -EAGAIN if that's not
41*4882a593Smuzhiyun 					possible. */
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #endif /* _UAPI_LINUX_OPENAT2_H */
44