Re: [RFC PATCH v2 1/2] vfs: syscalls: add mkdirat2() that returns an O_DIRECTORY fd
From: Jeff Layton
Date: Tue Apr 28 2026 - 03:01:46 EST
On Tue, 2026-04-28 at 07:39 +0100, Jeff Layton wrote:
> On Mon, 2026-04-27 at 17:48 +0200, Christian Brauner wrote:
> >
> >
> > And side-question: @Jeff, can nfs atomic open deal with O_CREAT |
> > O_DIRECTORY?
> >
>
> No, it can't. OPEN calls only work on regular files. This is why
> O_DIRECTORY works on NFS. If we end up issuing an OPEN against a
> directory, it'll fail, which is what we want in that situation.
To be clear, we could make that work by sending a second RPC:
PUTFH+OPEN+.... (OPEN fails with NFS4ERR_ISDIR)
...and then send:
PUTFH+CREATE...
...for a directory (which is how mkdir works in v4). If the calls race
with something else being created in its place, we could just open it
if it's a directory, or fail.
--
Jeff Layton <jlayton@xxxxxxxxxx>