[PATCH] tests: mv: add checks for cross device handling of special files
From:
Pádraig Brady
Subject:
[PATCH] tests: mv: add checks for cross device handling of special files
Date:
Mon, 1 Dec 2025 15:09:32 +0000
* tests/mv/mv-special-2.sh: Add test to ensure we preserve
sparse files, character devices, symlinks, when moving across
file system boundaries.
Addresses https://github.com/coreutils/coreutils/issues/136
---
tests/local.mk | 1 +
tests/mv/mv-special-2.sh | 62 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
create mode 100755 tests/mv/mv-special-2.sh
diff --git a/tests/local.mk b/tests/local.mk
index b7fb84e3e..17f850320 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -135,6 +135,7 @@ all_root_tests = \
tests/mkdir/smack-root.sh \
tests/mv/hardlink-case.sh \
tests/mv/sticky-to-xpart.sh \
+ tests/mv/mv-special-2.sh \
tests/rm/fail-2eperm.sh \
tests/rm/no-give-up.sh \
tests/rm/one-file-system.sh \
diff --git a/tests/mv/mv-special-2.sh b/tests/mv/mv-special-2.sh
new file mode 100755
index 000000000..fc259c760
--- /dev/null
+++ b/tests/mv/mv-special-2.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+# Ensure that mv works with non standard copies across file systems
+
+# Copyright (C) 2025 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ mv
+
+require_root_
+
+cwd=$(pwd)
+cleanup_() { cd /; umount "$cwd/xdev"; }
+
+skip=0
+
+# Mount an ext2 loopback file system at $WHERE
+make_fs() {
+ where="$1"
+
+ mkdir "$where" || framework_failure_
+
+ fs="$where.bin"
+ dd if=/dev/zero of="$fs" bs=8192 count=200 > /dev/null 2>&1 || skip=1
+ mkfs -t ext2 -F "$fs" || skip_ "failed to create ext2 file system"
+ mount -oloop "$fs" "$where" || skip=1
+
+ echo test > "$where"/f && test -s "$where"/f || skip=1
+
+ test $skip = 1 && skip_ 'insufficient mount/ext2 support'
+}
+
+make_fs xdev
+
+truncate -s 8G huge || framework_failure_
+mv --verbose huge xdev &&
+returns_ 1 test -e huge &&
+test -s xdev/huge || fail=1
+
+mknod devzero c 1 5 || framework_failure_
+mv --verbose devzero xdev &&
+returns_ 1 test -c devzero &&
+test -c xdev/devzero || fail=1
+
+ln -nsf blah blah || framework_failure_
+mv --verbose blah xdev &&
+returns_ 1 test -L blah &&
+test -L xdev/blah || fail=1
+
+Exit $fail
--
2.51.1
[Prev in Thread]
Current Thread
[Next in Thread]
[PATCH] tests: mv: add checks for cross device handling of special files,
Pádraig Brady<=