3 # Copyright (C) 2002 by Martin Pool <mbp@samba.org>
5 # This program is distributable under the terms of the GNU GPL (see
8 # Test rsync handling of devices. This can only run if you're root.
10 .
"$suitedir/rsync.fns"
12 # Build some hardlinks
16 $RSYNC --version |
grep "[, ] xattrs" >/dev
/null || test_skipped
"Rsync needs xattrs for fake device tests"
17 RSYNC
="$RSYNC --fake-super"
18 TLS_ARGS
="$TLS_ARGS --fake-super"
31 xattr
-s 'rsync.%stat' "$mode $maj,$min 0:0" "$fn"
45 runat
"$fn" "$SHELL_PATH" <<EOF
46 echo "$mode $maj,$min 0:0" > rsync.%stat
61 setextattr
-h user
"rsync.%stat" "$mode $maj,$min 0:0" "$fn"
75 setfattr
-n 'user.rsync.%stat' -v "$mode $maj,$min 0:0" "$fn"
82 root_uid
=`get_rootuid`
83 if test x
"$my_uid" = x
; then
84 : # If "id" failed, try to continue...
85 elif test x
"$my_uid" != x
"$root_uid"; then
86 if [ -e "$FAKEROOT_PATH" ]; then
87 echo "Let's try re-running the script under fakeroot..."
88 exec "$FAKEROOT_PATH" "$SHELL_PATH" $RUNSHFLAGS "$0"
90 test_skipped
"Rsync needs root/fakeroot for device tests"
95 # TODO: Need to test whether hardlinks are possible on this OS/filesystem
97 $RSYNC --version |
grep "[, ] hardlink-special" >/dev
/null
&& CAN_HLINK_SPECIAL
=yes || CAN_HLINK_SPECIAL
=no
101 mknod
"$fromdir/char" c
41 67 || test_skipped
"Can't create char device node"
102 mknod
"$fromdir/char2" c
42 68 || test_skipped
"Can't create char device node"
103 mknod
"$fromdir/char3" c
42 69 || test_skipped
"Can't create char device node"
104 mknod
"$fromdir/block" b
42 69 || test_skipped
"Can't create block device node"
105 mknod
"$fromdir/block2" b
42 73 || test_skipped
"Can't create block device node"
106 mknod
"$fromdir/block3" b
105 73 || test_skipped
"Can't create block device node"
107 if test "$CAN_HLINK_SPECIAL" = yes; then
108 ln "$fromdir/block3" "$fromdir/block3.5"
110 echo "Skipping hard-linked device test..."
112 mkfifo "$fromdir/fifo" || mknod
"$fromdir/fifo" p || test_skipped
"Can't run mkfifo"
113 # Work around time rounding/truncating issue by touching both files.
114 touch -r "$fromdir/block" "$fromdir/block" "$fromdir/block2"
116 checkdiff
"$RSYNC -ai '$fromdir/block' '$todir/block2'" <<EOT
120 checkdiff
"$RSYNC -ai '$fromdir/block2' '$todir/block'" <<EOT
126 checkdiff
"$RSYNC -Di '$fromdir/block3' '$todir/block'" <<EOT
130 cat >"$chkfile" <<EOT
135 hD$all_plus block3.5 => block3
141 if test "$CAN_HLINK_SPECIAL" = no
; then
142 grep -v block3.5
<"$chkfile" >"$chkfile.new"
143 mv "$chkfile.new" "$chkfile"
146 checkdiff2
"$RSYNC -aiHvv '$fromdir/' '$todir/'" v_filt
148 echo "check how the directory listings compare with diff:"
150 ( cd "$fromdir" && rsync_ls_lR .
) > "$tmpdir/ls-from"
151 ( cd "$todir" && rsync_ls_lR .
) > "$tmpdir/ls-to"
152 diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to"
154 if test "$CAN_HLINK_SPECIAL" = yes; then
156 checkdiff
"$RSYNC -aii --link-dest='$todir' '$fromdir/' '$chkdir/'" <<EOT
157 created directory $chkdir
170 # The script would have aborted on error, so getting here means we've won.