Bug 3692 - regression: symlinks are created as hardlinks with --link-dest
Summary: regression: symlinks are created as hardlinks with --link-dest
Status: CLOSED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 2.6.7
Hardware: x86 FreeBSD
: P3 major (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL: http://rsync.samba.org
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-17 00:41 UTC by hoffa
Modified: 2006-04-22 12:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hoffa 2006-04-17 00:41:21 UTC
hi. this refers to the official 2.6.7 release, no mods.
was working on verifying some older bugs and this one popped
up as new, it used to work ok. wanted to get it posted though
i've no patch. will gladly test any submitted.

regression: symlinks are created as hardlinks with --link-dest
the first run creates them erroneously as hardlinks.
a single repeat of the same command 'fixes' the mistake of the
first and should not be necessary.
the nth repeat of the same command does nothing because it's
now in sync.

by verbose example...


## show the current state of things
[] ls -aliT 0 1 2 3 4
ls: 1: No such file or directory
ls: 2: No such file or directory
ls: 3: No such file or directory
ls: 4: No such file or directory
0:
550260 drwxr-x---  2 moo moo       512 Apr 16 22:35:34 2006 .
415920 drwxr-xr-x  5 moo moo       512 Apr 17 00:46:06 2006 ..
550261 prw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 fifo0
550262 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard1
550262 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard2
550270 -rw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 file0
550271 -rw-rw----  2 moo moo         0 Jul 31 22:58:45 2005 filehard1
550271 -rw-rw----  2 moo moo         0 Jul 31 22:58:45 2005 filehard2
550263 brw-rw----  1 moo moo    2,   2 Aug  9 02:01:36 2005 nullb0
550264 brw-rw----  2 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard1
550264 brw-rw----  2 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard2
550265 crw-rw----  1 moo moo    2,   2 Aug  9 02:01:36 2005 nullc0
550266 crw-rw----  2 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard1
550266 crw-rw----  2 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard2
550267 srw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 socket0
550268 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard1
550268 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard2
550273 -rw-r-----  1 moo moo         0 Apr 16 21:47:16 2006 source0
550269 lrwxr-x---  1 moo moo         7 Apr 16 21:57:12 2006 target1 -> source0


## ok, now copy 0 to 1 using 0 as a reference...
#  the use of 0 as a reference when initializing the
#  first copy is valid though perhaps confusing. it also
#  happens to make writing backup scripts easier by
#  eliminating some initialization logic.
[] rsync -Haxv --delete --link-dest=`pwd`/0/ ./0/ ./1/
created directory ./1
./
fifo0
fifohard2
fifohard1 => fifohard2
socket0
sockethard2
sockethard1 => sockethard2

# ...hey where'd that hardlink come from and where's my symlink?
#  perhaps using link() instead of symlink().
[] ls -aliT 1
550259 drwxr-x---  2 moo moo       512 Apr 16 22:35:34 2006 .
415920 drwxr-xr-x  6 moo moo       512 Apr 17 00:47:08 2006 ..
550272 prw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 fifo0
550274 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard1
550274 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard2
550270 -rw-rw----  2 moo moo         0 Aug  9 02:01:36 2005 file0
550271 -rw-rw----  4 moo moo         0 Jul 31 22:58:45 2005 filehard1
550271 -rw-rw----  4 moo moo         0 Jul 31 22:58:45 2005 filehard2
550263 brw-rw----  2 moo moo    2,   2 Aug  9 02:01:36 2005 nullb0
550264 brw-rw----  4 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard1
550264 brw-rw----  4 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard2
550265 crw-rw----  2 moo moo    2,   2 Aug  9 02:01:36 2005 nullc0
550266 crw-rw----  4 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard1
550266 crw-rw----  4 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard2
550275 srw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 socket0
550276 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard1
550276 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard2
550273 -rw-r-----  3 moo moo         0 Apr 16 21:47:16 2006 source0
550273 -rw-r-----  3 moo moo         0 Apr 16 21:47:16 2006 target1

# lets see what happens if it's run again...
[] rsync -Haxv --delete --link-dest=`pwd`/0/ ./0/ ./1/
target1 -> source0

# ...the second run seems to have fixed the problem...
[] ls -aliT 1
550259 drwxr-x---  2 moo moo       512 Apr 16 22:35:34 2006 .
415920 drwxr-xr-x  6 moo moo       512 Apr 17 00:47:08 2006 ..
550272 prw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 fifo0
550274 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard1
550274 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard2
550270 -rw-rw----  2 moo moo         0 Aug  9 02:01:36 2005 file0
550271 -rw-rw----  4 moo moo         0 Jul 31 22:58:45 2005 filehard1
550271 -rw-rw----  4 moo moo         0 Jul 31 22:58:45 2005 filehard2
550263 brw-rw----  2 moo moo    2,   2 Aug  9 02:01:36 2005 nullb0
550264 brw-rw----  4 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard1
550264 brw-rw----  4 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard2
550265 crw-rw----  2 moo moo    2,   2 Aug  9 02:01:36 2005 nullc0
550266 crw-rw----  4 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard1
550266 crw-rw----  4 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard2
550275 srw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 socket0
550276 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard1
550276 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard2
550273 -rw-r-----  2 moo moo         0 Apr 16 21:47:16 2006 source0
550277 lrwxr-x---  1 moo moo         7 Apr 16 21:57:12 2006 target1 -> source0

# ...for sure? yes.
[] rsync -Haxv --delete --link-dest=`pwd`/0/ ./0/ ./1/
<nothing>


## ok, so lets try an incremented referential copy...
[] rsync -Haxv --delete --link-dest=`pwd`/1/ ./0/ ./2/
created directory ./2
./
fifo0
fifohard2
fifohard1 => fifohard2
socket0
sockethard2
sockethard1 => sockethard2

# ...same problem.
[] ls -aliT 2
550278 drwxr-x---  2 moo moo       512 Apr 16 22:35:34 2006 .
415920 drwxr-xr-x  7 moo moo       512 Apr 17 00:49:37 2006 ..
550279 prw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 fifo0
550280 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard1
550280 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard2
550270 -rw-rw----  3 moo moo         0 Aug  9 02:01:36 2005 file0
550271 -rw-rw----  6 moo moo         0 Jul 31 22:58:45 2005 filehard1
550271 -rw-rw----  6 moo moo         0 Jul 31 22:58:45 2005 filehard2
550263 brw-rw----  3 moo moo    2,   2 Aug  9 02:01:36 2005 nullb0
550264 brw-rw----  6 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard1
550264 brw-rw----  6 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard2
550265 crw-rw----  3 moo moo    2,   2 Aug  9 02:01:36 2005 nullc0
550266 crw-rw----  6 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard1
550266 crw-rw----  6 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard2
550281 srw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 socket0
550282 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard1
550282 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard2
550273 -rw-r-----  4 moo moo         0 Apr 16 21:47:16 2006 source0
550273 -rw-r-----  4 moo moo         0 Apr 16 21:47:16 2006 target1

# running the same thing again...
[] rsync -Haxv --delete --link-dest=`pwd`/1/ ./0/ ./2/
target1 -> source0

# ...fixes it.
[] ls -aliT 2
550278 drwxr-x---  2 moo moo       512 Apr 16 22:35:34 2006 .
415920 drwxr-xr-x  7 moo moo       512 Apr 17 00:49:37 2006 ..
550279 prw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 fifo0
550280 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard1
550280 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard2
550270 -rw-rw----  3 moo moo         0 Aug  9 02:01:36 2005 file0
550271 -rw-rw----  6 moo moo         0 Jul 31 22:58:45 2005 filehard1
550271 -rw-rw----  6 moo moo         0 Jul 31 22:58:45 2005 filehard2
550263 brw-rw----  3 moo moo    2,   2 Aug  9 02:01:36 2005 nullb0
550264 brw-rw----  6 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard1
550264 brw-rw----  6 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard2
550265 crw-rw----  3 moo moo    2,   2 Aug  9 02:01:36 2005 nullc0
550266 crw-rw----  6 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard1
550266 crw-rw----  6 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard2
550281 srw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 socket0
550282 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard1
550282 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard2
550273 -rw-r-----  3 moo moo         0 Apr 16 21:47:16 2006 source0
550283 lrwxr-x---  1 moo moo         7 Apr 16 21:57:12 2006 target1 -> source0


## so try the remaining permutation by using a broken reference
# to create a new copy.

# create the broken reference 3....
[] rsync -Haxv --delete --link-dest=`pwd`/2/ ./0/ ./3/
created directory ./3
./
fifo0
fifohard2
fifohard1 => fifohard2
socket0
sockethard2
sockethard1 => sockethard2

# ...broken as expected.
[] ls -aliT 3
550284 drwxr-x---  2 moo moo       512 Apr 16 22:35:34 2006 .
415920 drwxr-xr-x  8 moo moo       512 Apr 17 00:52:41 2006 ..
550285 prw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 fifo0
550286 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard1
550286 prw-rw----  2 moo moo         0 Aug  2 00:47:06 2005 fifohard2
550270 -rw-rw----  4 moo moo         0 Aug  9 02:01:36 2005 file0
550271 -rw-rw----  8 moo moo         0 Jul 31 22:58:45 2005 filehard1
550271 -rw-rw----  8 moo moo         0 Jul 31 22:58:45 2005 filehard2
550263 brw-rw----  4 moo moo    2,   2 Aug  9 02:01:36 2005 nullb0
550264 brw-rw----  8 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard1
550264 brw-rw----  8 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard2
550265 crw-rw----  4 moo moo    2,   2 Aug  9 02:01:36 2005 nullc0
550266 crw-rw----  8 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard1
550266 crw-rw----  8 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard2
550287 srw-rw----  1 moo moo         0 Aug  9 02:01:36 2005 socket0
550288 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard1
550288 srw-rw----  2 moo moo         0 Aug  4 02:05:00 2005 sockethard2
550273 -rw-r-----  5 moo moo         0 Apr 16 21:47:16 2006 source0
550273 -rw-r-----  5 moo moo         0 Apr 16 21:47:16 2006 target1

# now use it to make copy 4...
[] rsync -Haxv --delete --link-dest=`pwd`/3/ ./0/ ./4/
created directory ./4
./
fifo0
fifohard2
fifohard1 => fifohard2
socket0
sockethard2
sockethard1 => sockethard2
target1 -> source0

# ...which turns out to be correct, at least in meaning of 4 is the same as 0.
[] ls -aliT 4
550289 drwxr-x---   2 moo moo       512 Apr 16 22:35:34 2006 .
415920 drwxr-xr-x   9 moo moo       512 Apr 17 00:53:20 2006 ..
550290 prw-rw----   1 moo moo         0 Aug  9 02:01:36 2005 fifo0
550291 prw-rw----   2 moo moo         0 Aug  2 00:47:06 2005 fifohard1
550291 prw-rw----   2 moo moo         0 Aug  2 00:47:06 2005 fifohard2
550270 -rw-rw----   5 moo moo         0 Aug  9 02:01:36 2005 file0
550271 -rw-rw----  10 moo moo         0 Jul 31 22:58:45 2005 filehard1
550271 -rw-rw----  10 moo moo         0 Jul 31 22:58:45 2005 filehard2
550263 brw-rw----   5 moo moo    2,   2 Aug  9 02:01:36 2005 nullb0
550264 brw-rw----  10 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard1
550264 brw-rw----  10 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard2
550265 crw-rw----   5 moo moo    2,   2 Aug  9 02:01:36 2005 nullc0
550266 crw-rw----  10 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard1
550266 crw-rw----  10 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard2
550292 srw-rw----   1 moo moo         0 Aug  9 02:01:36 2005 socket0
550293 srw-rw----   2 moo moo         0 Aug  4 02:05:00 2005 sockethard1
550293 srw-rw----   2 moo moo         0 Aug  4 02:05:00 2005 sockethard2
550273 -rw-r-----   6 moo moo         0 Apr 16 21:47:16 2006 source0
550294 lrwxr-x---   1 moo moo         7 Apr 16 21:57:12 2006 target1 -> source0

# so try the same command again...
[] rsync -Haxv --delete --link-dest=`pwd`/3/ ./0/ ./4/
<nothing>

# ...looks ok.
[] ls -aliT 4
550289 drwxr-x---   2 moo moo       512 Apr 16 22:35:34 2006 .
415920 drwxr-xr-x   9 moo moo       512 Apr 17 00:53:20 2006 ..
550290 prw-rw----   1 moo moo         0 Aug  9 02:01:36 2005 fifo0
550291 prw-rw----   2 moo moo         0 Aug  2 00:47:06 2005 fifohard1
550291 prw-rw----   2 moo moo         0 Aug  2 00:47:06 2005 fifohard2
550270 -rw-rw----   5 moo moo         0 Aug  9 02:01:36 2005 file0
550271 -rw-rw----  10 moo moo         0 Jul 31 22:58:45 2005 filehard1
550271 -rw-rw----  10 moo moo         0 Jul 31 22:58:45 2005 filehard2
550263 brw-rw----   5 moo moo    2,   2 Aug  9 02:01:36 2005 nullb0
550264 brw-rw----  10 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard1
550264 brw-rw----  10 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard2
550265 crw-rw----   5 moo moo    2,   2 Aug  9 02:01:36 2005 nullc0
550266 crw-rw----  10 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard1
550266 crw-rw----  10 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard2
550292 srw-rw----   1 moo moo         0 Aug  9 02:01:36 2005 socket0
550293 srw-rw----   2 moo moo         0 Aug  4 02:05:00 2005 sockethard1
550293 srw-rw----   2 moo moo         0 Aug  4 02:05:00 2005 sockethard2
550273 -rw-r-----   6 moo moo         0 Apr 16 21:47:16 2006 source0
550294 lrwxr-x---   1 moo moo         7 Apr 16 21:57:12 2006 target1 -> source0

# and lets use a good reference for kicks...
[] rsync -Haxv --delete --link-dest=`pwd`/2/ ./0/ ./4/
<nothing>

# ...seems fine.
[] ls -aliT 4
550289 drwxr-x---   2 moo moo       512 Apr 16 22:35:34 2006 .
415920 drwxr-xr-x   9 moo moo       512 Apr 17 00:53:20 2006 ..
550290 prw-rw----   1 moo moo         0 Aug  9 02:01:36 2005 fifo0
550291 prw-rw----   2 moo moo         0 Aug  2 00:47:06 2005 fifohard1
550291 prw-rw----   2 moo moo         0 Aug  2 00:47:06 2005 fifohard2
550270 -rw-rw----   5 moo moo         0 Aug  9 02:01:36 2005 file0
550271 -rw-rw----  10 moo moo         0 Jul 31 22:58:45 2005 filehard1
550271 -rw-rw----  10 moo moo         0 Jul 31 22:58:45 2005 filehard2
550263 brw-rw----   5 moo moo    2,   2 Aug  9 02:01:36 2005 nullb0
550264 brw-rw----  10 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard1
550264 brw-rw----  10 moo moo    2,   2 Aug  4 01:48:48 2005 nullbhard2
550265 crw-rw----   5 moo moo    2,   2 Aug  9 02:01:36 2005 nullc0
550266 crw-rw----  10 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard1
550266 crw-rw----  10 moo moo    2,   2 Aug  4 01:50:01 2005 nullchard2
550292 srw-rw----   1 moo moo         0 Aug  9 02:01:36 2005 socket0
550293 srw-rw----   2 moo moo         0 Aug  4 02:05:00 2005 sockethard1
550293 srw-rw----   2 moo moo         0 Aug  4 02:05:00 2005 sockethard2
550273 -rw-r-----   6 moo moo         0 Apr 16 21:47:16 2006 source0
550294 lrwxr-x---   1 moo moo         7 Apr 16 21:57:12 2006 target1 -> source0


# end of bug, well, the report anyways.
Comment 1 hoffa 2006-04-17 02:41:17 UTC
try this...

seems at least freebsd, possibly others:
1 - won't link(2) directories, which is documented in man 2 link and man 1 ln.
2 - won't link(2) symlinks which doesn't seem to be documented anywhere except
 the 'object' bits in man 7 symlink, paragraph 1.
 we've lchmod(2), lchown(2), lstat(2), lutimes(2) and no linksymlink(2) ;-]
3 - will link(2) everything else [regular, block, char, fifo, sock].

ok, part 2. this was going to be a second bug.
in 2.6.7 as released, and using --link-dest...
 these are hardlinked between --link-dest and destination:
  regular
  block
  char
 these are not hardlinked between --link-dest and destination:
  fifo
  sock
  slink
...which is today inconsistant since all but slinks can be hardlinked.

one point of --link-dest being to save tons of bytes on disk.
so this might be solved, with consistancy, by making it look like either...
 hardlinked:
  regular
 not hardlinked:
  block
  char
  fifo
  sock
  slink
...or...
 hardlinked:
  regular
  block
  char
  fifo
  sock
 not hardlinked:
  slink
... . expense of the calls to make the perm/uid/gid/mtime identical vs.
checking to see if they exist in --link-dest.

note that of course any hardlink relationships between inodes in the
source would still have to be mirrored in each destination and
--link-dest, just not between --link-dest and destination.
Comment 2 Matt McCutchen 2006-04-17 11:06:07 UTC
Rsync's strange behavior is clearly the fault of BSD's link(2), which, as you implied, hardlinks symlink targets instead of the symlinks themselves.

The solution is to add a configure check that tests link(2) and defines/undefines CAN_HARDLINK_SYMLINKS appropriately.  If CAN_HARDLINK_SYMLINKS is not defined, then rsync would not consider --link-dest directories when transferring symlinks.
Comment 3 hoffa 2006-04-17 12:41:48 UTC
not sure of the wording 'hardlinks symlink targets'.

a symlink target is not what a symlink '->' points '->' to.
 at least as the bsd man page defines it. linux calls it a
 destination.
a 'hardlink of symlink target' would be the thin air bit in the
bsd part below, or as it turns out, how linux does it.

=== bsd section ===
link(2)  -  link(const char *name1, const char *name2);
 the link() function call atomically creates the specified directory entry (hard
 link) name2 with the attributes of the underlying object pointed at by name1.
ln(1)  -  ln source_file target_file

symlink(2)  -  symlink(const char *name1, const char *name2);
 a symbolic link name2 is created to name1 (name2 is the name of the file
 created, name1 is the string used in creating the symbolic link).
ln(1)  -  ln -s source_file target_file
http://www.freebsd.org/cgi/man.cgi?query=symlink&sektion=7

ls -aliT
 <nothing>
touch source0
ln -s source0 target0
ls -aliT
550260 -rw-r--r--  1 moo  moo    0 Apr 17 12:40:47 2006 source0
550261 lrwxr-xr-x  1 moo  moo    7 Apr 17 12:40:49 2006 target0 -> source0
*ln target0 trghrd0
ls -aliT          
550260 -rw-r--r--  2 moo  moo    0 Apr 17 12:40:47 2006 source0
550261 lrwxr-xr-x  1 moo  moo    7 Apr 17 12:40:49 2006 target0 -> source0
550260 -rw-r--r--  2 moo  moo    0 Apr 17 12:40:47 2006 trghrd0
note *:
 creates this entry [a hardlink of the source. link(2) follows the symlink and
 links(2)'s to the resulting underlying object, which is source0]
  550260 -rw-r--r--  2 moo  moo    0 Apr 17 12:40:47 2006 trghrd0
 rather than creating this one [a hardlink of the symlink itself [aka: target]].
 i typed this line from thin air, it doesn't really exist on disk.
  550261 lrwxr-xr-x  1 moo  moo    7 Apr 17 12:40:49 2006 trghrd0 -> source0

=== linux section ===
ls -ali
 <nothing>
touch source0
ln -s source0 target0
ln target0 trghrd0
ls -ali
 254046 -rw-r--r--   1 moo moo   0 Apr 17 13:03 source0
 254047 lrwxrwxrwx   2 moo moo   7 Apr 17 13:03 target0 -> source0
 254047 lrwxrwxrwx   2 moo moo   7 Apr 17 13:03 trghrd0 -> source0

=== ===
so yeah, some sort of platform #define combined with filing the rest of
the block, char, fifo, sock types under a consistant link or don't link
action as described in comment#1 above as well would be great.
Comment 4 Wayne Davison 2006-04-17 14:57:59 UTC
The latest CVS version (and "nightly" tar file) have this fixed.  You should re-run configure before running make because there are two new configure defines.
Comment 5 Matt McCutchen 2006-04-17 15:35:12 UTC
The new configure check for CAN_HARDLINK_SYMLINK should work, assuming that BSD's link(2) fails to follow the dangling symlink and fails with ENOENT.  However, there might be a pathological system whose link(2) hardlinks the symlink target if possible and otherwise the dangling symlink.

It would be safer if the configure script called link(2) on a good symlink and checked whether the result was a symlink using lstat(2) because this check is closer to rsync's use case.

Perhaps it would be a good idea in general for a receiving rsync, when it finishes with a file, to lstat the file again and warn the user if the file's preserved attributes differ from the attributes in its file-list entry.
Comment 6 hoffa 2006-04-18 15:28:59 UTC
note the 'initialization' bit in the description only works
when the source is on a different host/filesystem than
--link-dest and dest. otherwise you end up with most
of your snapshots being hardlinks to the source that
all track the properties therein. that was a bad example
to post ;-]

1) make the first copy without link-dest
 rsync -Haxv --delete                      ./0/         ./1/
 rsync -Haxv --delete --link-dest=`pwd`/1/ ./0/         ./2/
2) make --link-dest different than the source
 rsync -Haxv --delete --link-dest=`pwd`/0/ ./s/         ./1/
 rsync -Haxv --delete --link-dest=`pwd`/1/ ./s/         ./2/
3) ensure the source is on a different filesystem than link-dest and dest
 rsync -Haxv --delete --link-dest=/fs1/0/  /fs0/0/      /fs1/1/
 rsync -Haxv --delete --link-dest=/fs1/1/  /fs0/0/      /fs1/2/
 test if fsx are backed by same thing.
4) ensure the source is on a different host than link-dest and dest
 rsync -Haxv --delete --link-dest=/fs0/0/  host:/fs0/0/ /fs0/1/
 rsync -Haxv --delete --link-dest=/fs0/1/  host:/fs0/0/ /fs0/2/
 test if fsx are backed by same thing or host is self.