2 # Ensure that moving hard-linked arguments onto existing destinations works.
3 # Likewise when using cp --preserve=link.
5 # Copyright (C) 2003 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 if test "$VERBOSE" = yes; then
28 . $srcdir/../envvar-check
29 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
32 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
33 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
34 trap '(exit $?); exit $?' 1 2 13 15
37 mkdir -p $tmp || framework_failure=1
38 cd $tmp || framework_failure=1
39 mkdir dst || framework_failure=1
40 (cd dst && touch a b c) || framework_failure=1
41 touch a || framework_failure=1
42 ln a b || framework_failure=1
43 ln a c || framework_failure=1
45 if test $framework_failure = 1; then
46 echo "$0: failure in testing framework" 1>&2
52 # ======================================
53 cp --preserve=link a b c dst || fail=1
54 # The source files must remain.
60 # Three destination files must exist.
65 # The three i-node numbers must be the same.
66 ia=`ls -i a|sed 's/ a//'`
67 ib=`ls -i b|sed 's/ b//'`
68 ic=`ls -i c|sed 's/ c//'`
69 test $ia = $ib || fail=1
70 test $ia = $ic || fail=1
74 (cd dst && touch a b c)
76 # ======================================
77 mv a b c dst || fail=1
79 # The source files must be gone.
85 # Three destination files must exist.
90 # The three i-node numbers must be the same.
91 ia=`ls -i a|sed 's/ a//'`
92 ib=`ls -i b|sed 's/ b//'`
93 ic=`ls -i c|sed 's/ c//'`
94 test $ia = $ib || fail=1
95 test $ia = $ic || fail=1
97 (exit $fail); exit $fail