Re: [RFC PATCH 0/1] vfs: pass S_IFDIR mode to vfs_prepare_mode()
From: Jori Koolstra
Date: Thu Jun 11 2026 - 16:17:10 EST
> Op 11-06-2026 18:37 CEST schreef Al Viro <viro@xxxxxxxxxxxxxxxxxx>:
>
> There's a missing bit here: what's the point?
To clean up a bit ahead of O_CREAT|O_DIRECTORY. Specifically, in lookup_open()
we need to replace the vfs_prepare_mode() with something that also handles dirs.
I don't really want to push the odd
mode = vfs_prepare_mode(idmap, dir, mode, S_IRWXUGO | S_ISVTX, 0);
further into that code, and neither do I want this to be different from the
regular vfs_mkdir() path. We can then also match on S_IFMT in may_o_create(),
instead of passing a bool to signal whether we are creating a dir (and assuming
0 means a dir is really ugly).
This was discussed a bit in an rfc patch for O_CREAT|O_DIRECTORY, and Christian
said when he wrote that comment he "might've been overly cautious"[1]
I should have added this explanation to the commit message, you are right about
that. Thanks for pointing that out.
Best,
Jori.
[1]: https://lore.kernel.org/linux-fsdevel/20260527-fotowettbewerb-abwinken-einfach-83db3411945b@brauner/