2 # ensure that `cp -d' preserves hard-links between command line arguments
3 # ensure that --preserve=links works with -RH and -RL
5 # Copyright (C) 2001, 2002, 2004, 2006-2009 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 3 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, see <http://www.gnu.org/licenses/>.
20 if test "$VERBOSE" = yes; then
27 touch a || framework_failure
28 ln a b || framework_failure
29 mkdir c || framework_failure
30 cp -d a b c || framework_failure
31 test -f c/a || framework_failure
32 test -f c/b || framework_failure
35 a_inode=`ls -i c/a|sed 's,c/.*,,'`
36 b_inode=`ls -i c/b|sed 's,c/.*,,'`
37 test "$a_inode" = "$b_inode" || fail=1
38 # --------------------------------------
44 cp --preserve=links -R -H a b c
45 a_inode=`ls -i c/a|sed 's,c/.*,,'`
46 b_inode=`ls -i c/b|sed 's,c/.*,,'`
47 test "$a_inode" = "$b_inode" || fail=1
48 # --------------------------------------
50 # Ensure that -L makes cp follow the b->a symlink
51 # and translates to hard-linked a and b in the destination dir.
52 rm -rf a b c d; mkdir d; (cd d; touch a; ln -s a b)
53 cp --preserve=links -R -L d c
54 a_inode=`ls -i c/a|sed 's,c/.*,,'`
55 b_inode=`ls -i c/b|sed 's,c/.*,,'`
56 test "$a_inode" = "$b_inode" || fail=1
57 # --------------------------------------
59 # Same as above, but starting with a/b hard linked.
60 rm -rf a b c d; mkdir d; (cd d; touch a; ln a b)
61 cp --preserve=links -R -L d c
62 a_inode=`ls -i c/a|sed 's,c/.*,,'`
63 b_inode=`ls -i c/b|sed 's,c/.*,,'`
64 test "$a_inode" = "$b_inode" || fail=1
65 # --------------------------------------
67 # Ensure that --no-preserve=links works.
68 rm -rf a b c d; mkdir d; (cd d; touch a; ln a b)
69 cp -dR --no-preserve=links d c
70 a_inode=`ls -i c/a|sed 's,c/.*,,'`
71 b_inode=`ls -i c/b|sed 's,c/.*,,'`
72 test "$a_inode" = "$b_inode" && fail=1
73 # --------------------------------------
75 # Ensure that -d still preserves hard links.
80 a_inode=`ls -i c/a|sed 's,c/.*,,'`
81 b_inode=`ls -i c/b|sed 's,c/.*,,'`
82 test "$a_inode" = "$b_inode" || fail=1
83 # --------------------------------------
85 # Ensure that --no-preserve=mode works
89 cp -a --no-preserve=mode a b
90 mode=`ls -l b|cut -b-10`
91 test "$mode" = "-rwx------" || fail=1
93 # --------------------------------------