From: Pádraig Brady Date: Thu, 25 Jun 2026 20:03:00 +0000 (+0200) Subject: tests: mv: check cross-fs replacement with special files X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d2428b1f26c314e06adabb8c38e0ad6a74290b0b;p=thirdparty%2Fcoreutils.git tests: mv: check cross-fs replacement with special files * tests/mv/mv-special-1.sh: Moving a socket onto an existing file on another file system must replace that file, and not for example unlink the destination first and then fail, leaving the user with neither file. Link: https://github.com/coreutils/coreutils/pull/303 --- diff --git a/tests/mv/mv-special-1.sh b/tests/mv/mv-special-1.sh index fccdf6eee2..44f78fe59f 100755 --- a/tests/mv/mv-special-1.sh +++ b/tests/mv/mv-special-1.sh @@ -80,4 +80,21 @@ compare exp out2 || fail=1 # cd "$other_partition_tmpdir" # ls -l -A -R "$other_partition_tmpdir" +# Moving a special file across file systems onto an existing destination +# must replace that destination, not unlink it first and then fail, +# leaving the user with neither file. +source=mv-sock +if python -c "import socket as s; \ + s.socket(s.AF_UNIX).bind('$source'); \ + s.socket(s.AF_UNIX).bind('$other_partition_tmpdir/test.sock') \ + " && + test -S "$source" && test -S "$other_partition_tmpdir/test.sock"; then + + dest="$other_partition_tmpdir/mv-sock-dest" + touch "$dest" || framework_failure_ + mv "$source" "$dest" || fail=1 + test -S "$dest" || fail=1 # destination replaced by the socket + test -e "$source" && fail=1 # source removed +fi + Exit $fail