2 # Make sure we give a sensible diagnostic when a cross-device `mv'
3 # fails, e.g., because the destination cannot be unlinked.
4 # This is a bit fragile since it relies on the string used
5 # for EPERM: `permission denied'.
7 # Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 if test "$VERBOSE" = yes; then
29 . $srcdir/../other-fs-tmpdir
30 . $srcdir/../envvar-check
31 . $srcdir/../lang-default
32 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
35 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
36 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
37 trap '(exit $?); exit' 1 2 13 15
39 if test -z "$other_partition_tmpdir"; then
42 t0="$t0 $other_partition_tmpdir"
45 mkdir -p $tmp || framework_failure=1
46 cd $tmp || framework_failure=1
47 touch k $other_partition_tmpdir/k || framework_failure=1
48 chmod u-w $other_partition_tmpdir || framework_failure=1
50 if test $framework_failure = 1; then
51 echo "$0: failure in testing framework" 1>&2
57 mv -f k $other_partition_tmpdir 2> out && fail=1
59 mv: inter-device move failed: \`k' to \`$other_partition_tmpdir/k'; unable to remove target: Permission denied
62 # On some (less-compliant) systems, we get EPERM in this case.
63 # Accept either diagnostic.
65 mv: cannot move \`k' to \`$other_partition_tmpdir/k': Permission denied
68 if cmp out exp >/dev/null 2>&1; then
77 test $fail = 1 && diff out exp 2> /dev/null
79 (exit $fail); exit $fail