path: root/lib/libc
diff options
authorKonstantin Belousov <kib@FreeBSD.org>2021-05-06 17:16:53 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2021-05-10 23:39:24 +0000
commit5e7cdf1817924f8ae0333c0b53c2da32f35b65ea (patch)
tree0b9189206304a729b73c854fe1d6e1861bbeec39 /lib/libc
parentc55b340f824d353b7581e8ccf94ecd4929a41ea5 (diff)
openat(2): add O_EMPTY_PATH
It reopens the passed file descriptor, checking the file backing vnode' current access rights against open mode. In particular, this flag allows to convert file descriptor opened with O_PATH, into operable file descriptor, assuming permissions allow that. Reviewed by: markj Tested by: Andrew Walker <awalker@ixsystems.com> Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30148
Diffstat (limited to 'lib/libc')
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2
index a7806df69daf..5a6f161291f6 100644
--- a/lib/libc/sys/open.2
+++ b/lib/libc/sys/open.2
@@ -28,7 +28,7 @@
.\" @(#)open.2 8.2 (Berkeley) 11/16/93
.\" $FreeBSD$
-.Dd March 18, 2021
+.Dd May 6, 2021
.Dt OPEN 2
@@ -169,6 +169,7 @@ O_CLOEXEC set FD_CLOEXEC upon open
O_VERIFY verify the contents of the file
O_RESOLVE_BENEATH path resolution must not cross the fd directory
O_PATH record only the target path in the opened descriptor
+O_EMPTY_PATH openat, open file referenced by fd if path is empty
Opening a file with
@@ -355,6 +356,21 @@ are not allowed.
File opened with the
flag does not prevent non-forced unmount of the volume it belongs to.
+A file descriptor created with the
+flag can be opened into normal (operable) file descriptor by
+specifying it as the
+.Fa fd
+argument to
+.Fn openat
+with empty
+.Fa path
+and flag
+Such an open behaves as if the current path of the file referenced by
+.Fa fd
+is passed, except that the path walk permissions are not checked.
See also the description of
flag for