Bug#666024: rsync --link-dest can incorrectly hardlink together destination files

March 27th, 2012 - 05:40 pm ET by Ian Jackson | Report spam

Package: rsync
Version: 3.0.7-2

With rsync --link-dest, if two different source files (not hardlinked
to each other) are both candidates for being hardlinked from files of
the same name in the link-dest directory, both of them may be so
hardlinked. The effect is that on the destination the two files
become hardlined to each other even though they are not hardlinked
together in the source.

I discovered this because my backup system has a stage which checks
that the generated backup directory is truly semantically identical to
the source volume. When --link-dest is used in a backup mechanism the
effect is that if files were previously hardlinks on the source
volume, but something makes them no longer hardlinks by breaking the
link and copying the contents and attributes of the file, this change
is not reflected in the backups.

The bug can be reproduced with the attached shell script.
Run the script, and observe these lines in the output:
1390154 4 -rw-rw-r-- 4 ian ian 9 Mar 27 22:32 ./dst/b
1390154 4 -rw-rw-r-- 4 ian ian 9 Mar 27 22:32 ./dst/a
...
1390155 4 -rw-rw-r-- 1 ian ian 9 Mar 27 22:32 ./src/b
1390152 4 -rw-rw-r-- 1 ian ian 9 Mar 27 22:32 ./src/a
You can see that the inode numbers of src/a and src/b are different,
whereas the inode numbers of dst/a and dst/b are the same.

Thanks,
Ian.


filename="rsync-bug-repro"

#!/bin/sh
set -e
rm -rf d
mkdir d
cd d
set -x

mkdir src
echo contents >src/a
ln src/a src/b

rsync -aH src/. linkdest

rm src/b
cp -a src/a src/b

rsync -aH --link-dest=`pwd`/linkdest/. src/. dst

find -ls




To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
email Follow the discussionReplies 1 replyReplies Make a reply

Similar topics

Replies

#1 Ian Jackson
March 27th, 2012 - 05:50 pm ET | Report spam
I wrote:
With rsync --link-dest, if two different source files (not hardlinked
to each other) are both candidates for being hardlinked from files of
the same name in the link-dest directory, both of them may be so
hardlinked. The effect is that on the destination the two files
become hardlined to each other even though they are not hardlinked
together in the source.



That's garbled. I meant:

With rsync --link-dest, if two different source files (not hardlinked
to each other) have identical contents and are both candidates for
being hardlinked from files of their respective names in the link-dest
directory, and the link-dest files are hardlinks to each other, rsync
may wrongly make the two destination files hardlinks to each other.

Hopefully the test case script made this clear.

Ian.



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search