From: Jori Koolstra <jkoolstra@xs4all.nl>
To: Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Arnd Bergmann <arnd@arndb.de>
Cc: "H . Peter Anvin" <hpa@zytor.com>, "Jan Kara" <jack@suse.cz>,
"Peter Zijlstra" <peterz@infradead.org>,
"Andrey Albershteyn" <aalbersh@redhat.com>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Jori Koolstra" <jkoolstra@xs4all.nl>,
"Jiri Olsa" <jolsa@kernel.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
"Jeff Layton" <jlayton@kernel.org>,
"Aleksa Sarai" <cyphar@cyphar.com>,
cmirabil@redhat.com,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-api@vger.kernel.org, linux-arch@vger.kernel.org
Subject: [RFC PATCH v2 0/2] vfs: syscalls: add mkdirat2() that returns an O_DIRECTORY fd
Date: Sun, 12 Apr 2026 15:54:32 +0200 [thread overview]
Message-ID: <20260412135434.3095416-1-jkoolstra@xs4all.nl> (raw)
This series implements the mkdirat2() syscall that was suggested over
at the UAPI group kernel feature page [1] with some tests.
Obviously, we probably also want to implement equivalent mknodeat2() and
symlinkat2() syscalls, but their implementation can be done quite similar
I believe.
This has been compiled and tested on x86 only.
[1]: https://github.com/uapi-group/kernel-features?tab=readme-ov-file#race-free-creation-and-opening-of-non-file-inodes
v2:
- Use AT_* flags.
- Ensure an fd is allocated only if mkdir and open_dentry succeed.
- The returned fd gets O_CLOEXEC by default.
- Renamed syscall from mkdirat_fd() to mkdirat2().
Jori Koolstra (2):
vfs: syscalls: add mkdirat2() that returns an O_DIRECTORY fd
selftest: add tests for mkdirat2()
arch/x86/entry/syscalls/syscall_64.tbl | 1 +
fs/internal.h | 2 +
fs/namei.c | 44 +++++-
include/linux/syscalls.h | 2 +
include/uapi/asm-generic/unistd.h | 5 +-
scripts/syscall.tbl | 1 +
tools/include/uapi/asm-generic/unistd.h | 5 +-
.../testing/selftests/filesystems/.gitignore | 1 +
tools/testing/selftests/filesystems/Makefile | 4 +-
.../selftests/filesystems/mkdirat_fd_test.c | 143 ++++++++++++++++++
10 files changed, 200 insertions(+), 8 deletions(-)
create mode 100644 tools/testing/selftests/filesystems/mkdirat_fd_test.c
--
2.53.0
next reply other threads:[~2026-04-12 13:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 13:54 Jori Koolstra [this message]
2026-04-12 13:54 ` [RFC PATCH v2 1/2] vfs: syscalls: add mkdirat2() that returns an O_DIRECTORY fd Jori Koolstra
2026-04-12 13:54 ` [RFC PATCH v2 2/2] selftest: add tests for mkdirat2() Jori Koolstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260412135434.3095416-1-jkoolstra@xs4all.nl \
--to=jkoolstra@xs4all.nl \
--cc=aalbersh@redhat.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=brauner@kernel.org \
--cc=cmirabil@redhat.com \
--cc=cyphar@cyphar.com \
--cc=dave.hansen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox