git: cc0d806f63e8 - main - open(2): allow O_PATH | O_CREAT

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 07 Jan 2025 02:46:36 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=cc0d806f63e833b9e011c0665905b2208b436c8b

commit cc0d806f63e833b9e011c0665905b2208b436c8b
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-01-06 11:01:11 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-01-07 02:46:18 +0000

    open(2): allow O_PATH | O_CREAT
    
    There is no reason to disallow creating the file opened for path.
    More, it might be a useful feature together with O_EXCL.
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D48332
---
 sys/kern/vfs_syscalls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 7a1677c945e3..bbd67c2b0326 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1185,7 +1185,7 @@ openatfp(struct thread *td, int dirfd, const char *path,
 	 * except O_EXEC is ignored.
 	 */
 	if ((flags & O_PATH) != 0) {
-		flags &= ~(O_CREAT | O_ACCMODE);
+		flags &= ~O_ACCMODE;
 	} else if ((flags & O_EXEC) != 0) {
 		if (flags & O_ACCMODE)
 			return (EINVAL);