On 3/1/24 05:05, Petr Malat wrote: > Hi! > On Fri, Mar 01, 2024 at 09:18:31AM +0000, Padraig Brady wrote: >> On 29/02/2024 22:02, Petr Malat wrote: >> > renameat2() syscall allows atomically swapping 2 paths on one >> > file system. Expose this ability to the user using -s option. >> > >> > * NEWS: Mention the new option >> >> Thanks for the patch. >> >> That was suggested previously: >> https://lists.gnu.org/archive/html/coreutils/2021-05/msg00030.html >> >> I agree this is useful functionality, >> but the thinking is we should add this to a "replace" utility >> rather than to mv. > > I have modified mv, because for me it would be a logical place where > to look for such a feature, and to make something usable, it must be > easy to find.
I used "mv -x" for it, but if you have a strong preference for -s it hasn't been in a release version yet. I can submit a patch to busybox to add it there if we agree on a UI. (I will not be adding a "replace" command to toybox: mv already replaces files and this is a flag to the rename() system call that "mv" is already built around. This is an atomic exchange, the new flag is RENAME_EXCHANGE, hence "-x" meaning exchange.) Rob