]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Avoid re-setting xattrs on a hard-linked file w/the same xattrs.
authorWayne Davison <wayned@samba.org>
Sat, 26 Mar 2011 16:15:26 +0000 (09:15 -0700)
committerWayne Davison <wayned@samba.org>
Sat, 26 Mar 2011 17:01:37 +0000 (10:01 -0700)
Improved the xattrs testing to include hard-linking.

.gitignore
Makefile.in
NEWS
receiver.c
testsuite/hardlinks.test
testsuite/xattrs.test

index 76693bb409ee6d859b5f974e180c45093072f29e..1fea441f96a427d0d6002643e8195fba0dee3ba1 100644 (file)
@@ -38,4 +38,5 @@ config.status
 /support/savetransfer
 /testsuite/chown-fake.test
 /testsuite/devices-fake.test
+/testsuite/xattrs-hlink.test
 /patches
index 38986da7bb73325c3c89dba774f45fb05730eae9..6f753acf421658b7770f27eb44afd345037c4327 100644 (file)
@@ -48,7 +48,7 @@ TLS_OBJ = tls.o syscall.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxa
 CHECK_PROGS = rsync$(EXEEXT) tls$(EXEEXT) getgroups$(EXEEXT) getfsdev$(EXEEXT) \
        trimslash$(EXEEXT) t_unsafe$(EXEEXT) wildtest$(EXEEXT)
 
-CHECK_SYMLINKS = testsuite/chown-fake.test testsuite/devices-fake.test
+CHECK_SYMLINKS = testsuite/chown-fake.test testsuite/devices-fake.test testsuite/xattrs-hlink.test
 
 # Objects for CHECK_PROGS to clean
 CHECK_OBJS=tls.o getgroups.o getfsdev.o t_stub.o t_unsafe.o trimslash.o wildtest.o
@@ -249,6 +249,9 @@ testsuite/chown-fake.test:
 testsuite/devices-fake.test:
        ln -s devices.test $(srcdir)/testsuite/devices-fake.test
 
+testsuite/xattrs-hlink.test:
+       ln -s xattrs.test $(srcdir)/testsuite/xattrs-hlink.test
+
 # This does *not* depend on building or installing: you can use it to
 # check a version installed from a binary or some other source tree,
 # if you want.
diff --git a/NEWS b/NEWS
index 625c27bbe50ca224f711afa47ff6269f96db0931..182261456ea88f0f57e3abaf4804c2bc044a1bfb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -83,6 +83,8 @@ Changes since 3.0.7:
 
     - Fixed a bug setting xattrs on new files that aren't user writable.
 
+    - Avoid re-setting xattrs on a hard-linked file w/the same xattrs.
+
     - Fixed a bug with --fake-super when copying files and dirs that aren't
       user writable.
 
index fc7ab57537f47e5094e097059dfece78a0fa32da..d90fa25fc7dd3366a6f5a18ab6ff58075544f49e 100644 (file)
@@ -503,14 +503,15 @@ int recv_files(int f_in, char *local_name)
                        rprintf(FINFO, "recv_files(%s)\n", fname);
 
 #ifdef SUPPORT_XATTRS
-               if (iflags & ITEM_REPORT_XATTR && do_xfers)
+               if (preserve_xattrs && iflags & ITEM_REPORT_XATTR && do_xfers)
                        recv_xattr_request(file, f_in);
 #endif
 
                if (!(iflags & ITEM_TRANSFER)) {
                        maybe_log_item(file, iflags, itemizing, xname);
 #ifdef SUPPORT_XATTRS
-                       if (preserve_xattrs && iflags & ITEM_REPORT_XATTR && do_xfers)
+                       if (preserve_xattrs && iflags & ITEM_REPORT_XATTR && do_xfers
+                        && !BITS_SET(iflags, ITEM_XNAME_FOLLOWS|ITEM_LOCAL_CHANGE))
                                set_file_attrs(fname, file, NULL, fname, 0);
 #endif
                        continue;
index 1737b3528566f940fa570a7871545c606983614e..a0db2d033d51d2f1aa68239223de040835dda6c5 100644 (file)
@@ -28,7 +28,7 @@ name2="$fromdir/name2"
 name3="$fromdir/name3"
 name4="$fromdir/name4"
 echo "This is the file" > "$name1"
-ln "$name1" "$name2" || fail "Can't create hardlink"
+ln "$name1" "$name2" || test_skipped "Can't create hardlink"
 ln "$name2" "$name3" || fail "Can't create hardlink"
 cp "$name2" "$name4" || fail "Can't copy file"
 cat $srcdir/*.c >"$fromdir/text"
index 97056b7f5022c57128ac1a66503d03ccec218b7e..50e262be39e13abbcc7b46d5ef3c2771b91a39b7 100644 (file)
@@ -6,6 +6,7 @@
 # Test that rsync handles basic xattr preservation.
 
 . $srcdir/testsuite/rsync.fns
+lnkdir="$tmpdir/lnk"
 
 $RSYNC --version | grep ", xattrs" >/dev/null || test_skipped "Rsync is configured without xattr support"
 
@@ -38,7 +39,7 @@ case "`xattr 2>&1`" in
     ;;
 esac
 
-makepath "$fromdir/foo/bar"
+makepath "$lnkdir" "$fromdir/foo/bar"
 echo now >"$fromdir/file0"
 echo something >"$fromdir/file1"
 echo else >"$fromdir/file2"
@@ -73,32 +74,60 @@ xset user.dir1 'need to test directory xattrs too' foo
 xset user.dir2 'another xattr' foo
 xset user.dir3 'this is one last one for the moment' foo
 
+xset user.dir4 'another dir test' foo/bar
+xset user.dir5 'one last one' foo/bar
+
 xset user.foo 'new foo' foo/file3 foo/bar/file5
 xset user.bar 'new bar' foo/file3 foo/bar/file5
 xset user.long 'this is also a long attribute that will be truncated in the initial data send' foo/file3 foo/bar/file5
 xset $RUSR.equal 'this long attribute should remain the same and not need to be transferred' foo/file3 foo/bar/file5
 
+xset user.dir0 'old extra value' "$chkdir/foo"
+xset user.dir1 'old dir value' "$chkdir/foo"
+
 xset user.short 'old short' "$chkdir/file1"
 xset user.extra 'remove me' "$chkdir/file1"
 
 xset user.foo 'old foo' "$chkdir/foo/file3"
 xset $RUSR.equal 'this long attribute should remain the same and not need to be transferred' "$chkdir/foo/file3"
 
+case $0 in
+*hlink*)
+    ln foo/bar/file5 foo/bar/file6 || test_skipped "Can't create hardlink"
+    files="$files foo/bar/file6"
+    dashH='-H'
+    altDest='--link-dest'
+    ;;
+*)
+    dashH=''
+    altDest='--copy-dest'
+    ;;
+esac
+
 xls $dirs $files >"$scratchdir/xattrs.txt"
 
 # OK, let's try a simple xattr copy.
-checkit "$RSYNC -avX --super . '$chkdir/'" "$fromdir" "$chkdir"
+checkit "$RSYNC -avX $dashH --super . '$chkdir/'" "$fromdir" "$chkdir"
 
 cd "$chkdir"
 xls $dirs $files | diff $diffopt "$scratchdir/xattrs.txt" -
 
 cd "$fromdir"
 
-checkit "$RSYNC -aiX --super --copy-dest=../chk . ../to" "$fromdir" "$todir"
+if [ "$dashH" ]; then
+    for fn in $files; do
+       name=`basename $fn`
+       ln $fn ../lnk/$name
+    done
+fi
+
+checkit "$RSYNC -aiX $dashH --super $altDest=../chk . ../to" "$fromdir" "$todir"
 
 cd "$todir"
 xls $dirs $files | diff $diffopt "$scratchdir/xattrs.txt" -
 
+[ "$dashH" ] && rm -rf "$lnkdir"
+
 cd "$fromdir"
 rm -rf "$todir"
 
@@ -106,7 +135,7 @@ xset user.nice 'this is nice, but different' file1
 
 xls $dirs $files >"$scratchdir/xattrs.txt"
 
-checkit "$RSYNC -aiX --fake-super --link-dest=../chk . ../to" "$chkdir" "$todir"
+checkit "$RSYNC -aiX $dashH --fake-super --link-dest=../chk . ../to" "$chkdir" "$todir"
 
 cd "$todir"
 xls $dirs $files | diff $diffopt "$scratchdir/xattrs.txt" -
@@ -136,7 +165,7 @@ cd "$fromdir"
 rm -rf "$todir"
 
 # When run by a non-root tester, this checks if no-user-perm files/dirs can be copied.
-checkit "$RSYNC -aiX --fake-super --chmod=a= . ../to" "$chkdir" "$todir" # 2>"$scratchdir/errors.txt"
+checkit "$RSYNC -aiX $dashH --fake-super --chmod=a= . ../to" "$chkdir" "$todir" # 2>"$scratchdir/errors.txt"
 
 cd "$todir"
 xls $dirs $files | diff $diffopt "$scratchdir/xattrs.txt" -
@@ -148,10 +177,13 @@ $RSYNC -aX file1 file2
 $RSYNC -aX file1 file2 ../chk/
 $RSYNC -aX --del ../chk/ .
 $RSYNC -aX file1 ../lnk/
+[ "$dashH" ] && ln "$chkdir/file1" ../lnk/extra-link
 
 xls file1 file2 >"$scratchdir/xattrs.txt"
 
-checkit "$RSYNC -aiiX --copy-dest=../lnk . ../to" "$chkdir" "$todir"
+checkit "$RSYNC -aiiX $dashH $altDest=../lnk . ../to" "$chkdir" "$todir"
+
+[ "$dashH" ] && rm ../lnk/extra-link
 
 cd "$todir"
 xls file1 file2 | diff $diffopt "$scratchdir/xattrs.txt" -