Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F131915856
D30148.id88969.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D30148.id88969.diff
View Options
diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2
--- 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
.Os
.Sh NAME
@@ -169,6 +169,7 @@
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
.Ed
.Pp
Opening a file with
@@ -355,6 +356,21 @@
File opened with the
.Dv O_PATH
flag does not prevent non-forced unmount of the volume it belongs to.
+.Pp
+A file descriptor created with the
+.Dv O_PATH
+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
+.Dv O_EMPTY_PATH .
+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
.Dv AT_EMPTY_PATH
flag for
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -200,6 +200,8 @@
res = ISOPEN | LOCKLEAF;
if ((fmode & O_RESOLVE_BENEATH) != 0)
res |= RBENEATH;
+ if ((fmode & O_EMPTY_PATH) != 0)
+ res |= EMPTYPATH;
if ((vn_open_flags & VN_OPEN_NOAUDIT) == 0)
res |= AUDITVNODE1;
if ((vn_open_flags & VN_OPEN_NOCAPCHECK) != 0)
diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h
--- a/sys/sys/fcntl.h
+++ b/sys/sys/fcntl.h
@@ -141,6 +141,9 @@
#endif
#define O_DSYNC 0x01000000 /* POSIX data sync */
+#if __BSD_VISIBLE
+#define O_EMPTY_PATH 0x02000000
+#endif
/*
* XXX missing O_RSYNC.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 13, 4:48 AM (14 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23658036
Default Alt Text
D30148.id88969.diff (1 KB)
Attached To
Mode
D30148: openat(2): add O_EMPTY_PATH flag
Attached
Detach File
Event Timeline
Log In to Comment