DO NOT REPLY [Bug 4079] rsync fails with --inplace, --link-dest and --no-whole-file

samba-bugs at samba.org samba-bugs at samba.org
Mon Sep 4 15:57:44 GMT 2006


https://bugzilla.samba.org/show_bug.cgi?id=4079





------- Comment #2 from roger at planbit.co.uk  2006-09-04 10:57 MST -------
The patch below will detect the condition where we are "inplace", have a
destination file that does not exist and an existing reference file.  When this
happens, the destination file will be hardlinked to the reference file before
being opened.  This resolves the bug.  There is probably a cleaner way of
detecting the missing destination file than trying to open it read-only and
handling the fail state.

There is also the question of whether this is the correct behaviour since the
modifications also get applied to the reference file because of the hard-link. 
For me, the hard-link is what I would want to happen, but other people may
prefer to have rsync copy the matching data from the reference file to the
destination file so that the reference file is left unchanged.

diff -aur rsync-2.6.8/receiver.c wip/receiver.c
--- rsync-2.6.8/receiver.c      2006-09-04 16:48:46.000000000 +0100
+++ wip/receiver.c      2006-09-04 16:46:43.000000000 +0100
@@ -560,6 +560,21 @@

                /* We now check to see if we are writing file "inplace" */
                if (inplace)  {
+
+                       if ((fd1 != -1) && (fname != fnamecmp))
+                       {
+                               fd2 = do_open(fname, O_RDONLY, 0);
+                               if (fd2 < 0)
+                               {
+                                       rprintf(FINFO,"Adding hard-link %s ->
%s\n", fname, fnamecmp);
+                                       do_link(fnamecmp, fname);
+                               }
+                   else
+                               {
+                                       close(fd2);
+                               }
+                       }
+
                        fd2 = do_open(fname, O_WRONLY|O_CREAT, 0600);
                        if (fd2 == -1) {
                                rsyserr(FERROR, errno, "open %s failed",


-- 
Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.


More information about the rsync mailing list