On Thu, Apr 2, 2026 at 4:52 AM Aleksa Sarai <[email protected]> wrote: > > On 2026-04-01, Mateusz Guzik <[email protected]> wrote: > > Trying to handle this in open() is a no-go. openat2 is rather > > problematic. > > I'm interested in what makes you say that. It would be very nice to be able > to do mkdir + RESOLVE_IN_ROOT and get an fd back all in one syscall. :D >
Not handling this in either of open or openat2 does not preclude mkdir + RESOLVE_IN_ROOT + getting a fd in one go from existing. Creating a directory was always a different syscall than creating a file. I don't see any benefit to squeezing it into open. I do see a downside because of an extra branchfest to differentiate the cases. > > The routine would have to start with validating the passed O_ flags, for > > now only allowing O_CLOEXEC and EINVAL-ing otherwise. > > Please do not use O_* flags! O_CLOEXEC takes up 3 flag bits on different > architectures which makes adding new flags a nightmare. > With my proposal there are no new flags added so I don't think that's relevant. > I think this should take AT_* flags and (like most newer syscalls) > O_CLOEXEC should be automatically set. Userspace can unset it with > fnctl(F_SETFD) in the relatively rare case where they don't want > O_CLOEXEC. Alternatively, we could just bite the bullet and make > AT_NO_CLOEXEC a thing... > I would say that's a pretty weird discrepancy vs what normally happens with other syscalls, but perhaps it would be fine.

