Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: expose LOOKUP_CACHED through openat2() RESOLVE_CACHED

Now that we support non-blocking path resolution internally, expose it
via openat2() in the struct open_how ->resolve flags. This allows
applications using openat2() to limit path resolution to the extent that
it is already cached.

If the lookup cannot be satisfied in a non-blocking manner, openat2(2)
will return -1/-EAGAIN.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Jens Axboe and committed by
Al Viro
99668f61 6c6ec2b0

+11 -1
+6
fs/open.c
··· 1091 1091 lookup_flags |= LOOKUP_BENEATH; 1092 1092 if (how->resolve & RESOLVE_IN_ROOT) 1093 1093 lookup_flags |= LOOKUP_IN_ROOT; 1094 + if (how->resolve & RESOLVE_CACHED) { 1095 + /* Don't bother even trying for create/truncate/tmpfile open */ 1096 + if (flags & (O_TRUNC | O_CREAT | O_TMPFILE)) 1097 + return -EAGAIN; 1098 + lookup_flags |= LOOKUP_CACHED; 1099 + } 1094 1100 1095 1101 op->lookup_flags = lookup_flags; 1096 1102 return 0;
+1 -1
include/linux/fcntl.h
··· 19 19 /* List of all valid flags for the how->resolve argument: */ 20 20 #define VALID_RESOLVE_FLAGS \ 21 21 (RESOLVE_NO_XDEV | RESOLVE_NO_MAGICLINKS | RESOLVE_NO_SYMLINKS | \ 22 - RESOLVE_BENEATH | RESOLVE_IN_ROOT) 22 + RESOLVE_BENEATH | RESOLVE_IN_ROOT | RESOLVE_CACHED) 23 23 24 24 /* List of all open_how "versions". */ 25 25 #define OPEN_HOW_SIZE_VER0 24 /* sizeof first published struct */
+4
include/uapi/linux/openat2.h
··· 35 35 #define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".." 36 36 be scoped inside the dirfd 37 37 (similar to chroot(2)). */ 38 + #define RESOLVE_CACHED 0x20 /* Only complete if resolution can be 39 + completed through cached lookup. May 40 + return -EAGAIN if that's not 41 + possible. */ 38 42 39 43 #endif /* _UAPI_LINUX_OPENAT2_H */