Re: [PATCH] do_open(): Fix O_DIRECTORY | O_CREAT behavior

From: Josh Triplett
Date: Tue Mar 28 2023 - 00:00:59 EST


On March 28, 2023 12:32:59 PM GMT+09:00, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>Ok, just to play along - maybe you can make it slightly less
>nonsensical by throwing O_PATH into the mix, and now an empty
>directory file descriptor at least has *some* use.

That's the case I was thinking of: create a directory, then use exclusively *at system calls, never anything path-based. (I was using "atomic" loosely; not concerned about races here, just convenience.)

>Now your code would not only be specific to Linux, it would be
>specific to some very new version of Linux, and do something
>completely different on older versions.

I'm extremely not concerned with depending on current Linux. But that said...

>Because those older versions will do random things, ranging from
>"always return an error" to "create a regular file - not a directory -
>and then return an error anyway" and finally "create a regular file -
>not a directory - and return that resulting fd".

... Right, open has the un-extendable semantics, hence O_TMPFILE. Fair enough. Nevermind then.

As is often the case for multi-operation syscalls, I'm better off just using io_uring for a mkdir-then-open.