On Linux, cap-std implements Dir::rename via rustix::fs::renameat, which is the renameat function.
Since Linux 3.15, there is another version of this call, renameat2, which supports an additional flags argument. rustix already supports this function as rustix::fs::renameat_with.
Could cap-std add support for this function as well?
Additional Context
The external cap-std-ext crate implements atomic writes by writing a temporary file and renaming it in place. However, it is not possible to atomically create a file in this way.
renameat2 supports the RENAME_NOREPLACE flag, which ensures that no existing file is overwritten by the rename. As such, an atomic_create could be implemented based on this change.
On Linux,
cap-stdimplementsDir::renameviarustix::fs::renameat, which is therenameatfunction.Since Linux 3.15, there is another version of this call,
renameat2, which supports an additionalflagsargument.rustixalready supports this function asrustix::fs::renameat_with.Could
cap-stdadd support for this function as well?Additional Context
The external
cap-std-extcrate implements atomic writes by writing a temporary file and renaming it in place. However, it is not possible to atomically create a file in this way.renameat2supports theRENAME_NOREPLACEflag, which ensures that no existing file is overwritten by the rename. As such, anatomic_createcould be implemented based on this change.