nix-rust / nix

Rust friendly bindings to *nix APIs
MIT License
2.63k stars 661 forks source link

linkat doesn't support AT_EMPTY_PATH, making it incompatible with O_TMPFILE #2362

Closed vlovich closed 5 months ago

vlovich commented 5 months ago

If you want to linkat a file created with O_TMPFILE and without O_EXCL, then you need to pass an empty path for oldpath, the O_TMPFILE fd, and AT_EMPTY_PATH. However, the linkat flags are an enum and don't support AT_EMPTY_PATH to be provided.

The alternate workaround is to blindly assume that the proc filesystem is mounted (& mounted at /proc) & construct a path to the O_TMPFILE fd with follow symlinks set to true.

SteveLauC commented 5 months ago

However, the linkat flags are an enum and don't support AT_EMPTY_PATH to be provided.

Try bumping your Nix dependency to 0.28.0, you can specify AT_EMPTY_PATH now

https://docs.rs/nix/latest/nix/unistd/fn.linkat.html

SteveLauC commented 5 months ago

Close this issue but feel free to reopen it if you think it is still not resolved