Problem/fix combining -A and --link-dest

Andrew Gideon c172driver99820 at tagonline.com
Sun Feb 27 17:50:40 GMT 2005


I'm using the -A patch on v2.6.2, and I'm doing the usual "incremental 
backup using links" thing.  The destination is a machine running Fedora 
(both 2 and 3), and the sources are machines running various Linuxes and 
Solaris.

During my initial testing, I found a lot of diskspace being wasted.  I 
traced this back to files being copied when a link would suffice.  I found 
that this was caused by a difference between how Solaris and Linux returned 
a file's mode from stat() when ACLs are in use.

Looking further into this, I also found that rsync would not copy a file 
(even between two Linux machines) if the ACLs had changed; it would leave
the link in place.

In other words, ACLs weren't being properly considered when determining 
whether to link or copy a file.

I built into my version a fix.  Has this already been fixed in 2.6.3 or the 
upcoming .4, or is someone interested in what I did?

What I did was pretty simple.  To acls.c I added a function 
test_if_acls_match().  I then modified skip_file() in generator.c to use 
this, instead of stat()'s modes, if both link_dest and preserve_acls are 
set.  

This solves both of the above problems.  The differences in stat()'s return 
of modes between Linux and Solaris is avoided because skip_file() isn't 
looking at the modes of the old and new files; it's looking at the ACLs.  
And because it is looking at the ACLs, it'll see that a copy is needed if 
there's been an ACL change but no other change.

None of what I did is especially complex.  But if this hasn't yet been fixed 
in the repository, and if someone wants to see what I've done, I'm happy to 
send it.  This was my first peek at the rsync code, though, so I provide no 
guarantee that this is the best way of achieving the fix.  Nor did I 
consider the case of using --delete instead of --link-dest, or using
neither.

        - Andrew



More information about the rsync mailing list