[PATCH] tests: mv: check cross-fs replacement with special files
From:
Pádraig Brady
Subject:
[PATCH] tests: mv: check cross-fs replacement with special files
Date:
Tue, 30 Jun 2026 19:06:08 +0100
* 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
---
tests/mv/mv-special-1.sh | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/tests/mv/mv-special-1.sh b/tests/mv/mv-special-1.sh
index fccdf6eee..44f78fe59 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
--
2.54.0
[Prev in Thread]
Current Thread
[Next in Thread]
[PATCH] tests: mv: check cross-fs replacement with special files,
Pádraig Brady<=