1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 11:16:16 +02:00

mv: add --swap (-x) option to atomically swap 2 paths

renameat2() syscall allows atomically swapping 2 paths on one
file system. Expose this ability to the user with --swap.

* doc/coreutils.texi: Describe mv --swap option.
* src/mv.c (main): Support --swap.
* tests/mv/mv-swap.sh: Add test for mv -x.
* tests/local.mk: Reference new test.
* NEWS: Mention the new option.
This commit is contained in:
Petr Malat
2024-02-29 23:02:03 +01:00
committed by Pádraig Brady
parent fcfba90d0d
commit 6cd2d5e533
5 changed files with 99 additions and 1 deletions

View File

@@ -10302,6 +10302,16 @@ to cause @command{cp} write to arbitrary target directories.
@optBackupSuffix
@item -x
@itemx --swap
@opindex -x
@opindex --swap
@cindex swapping files
Atomically exchange all data and metadata for two specified files.
They can be of a different type,
but must exist and reside on the same file system.
If the atomic swap is not supported, exit with failure status.
@optTargetDirectory
@optNoTargetDirectory