c6934561fd1ac534ec711c6deadab905b2856f5a
[rsync-patches.git] / soften-links.diff
1 Marco d'Itri wrote:
2
3 I run one of the debian mirrors, and I had to write this patch because
4 my archive is split between more than one disk. Would you accept a more
5 polished version of this patch for inclusion in rsync?
6
7 To use this patch, run these commands for a successful build:
8
9     patch -p1 <patches/soften-links.diff
10     ./configure                           (optional if already run)
11     make
12
13 based-on: 9a06b2edb0ea1a226bcc642682c07bacd2ea47d3
14 diff --git a/syscall.c b/syscall.c
15 --- a/syscall.c
16 +++ b/syscall.c
17 @@ -136,13 +136,18 @@ ssize_t do_readlink(const char *path, char *buf, size_t bufsiz)
18  #if defined HAVE_LINK || defined HAVE_LINKAT
19  int do_link(const char *old_path, const char *new_path)
20  {
21 +       int st;
22 +
23         if (dry_run) return 0;
24         RETURN_ERROR_IF_RO_OR_LO;
25  #ifdef HAVE_LINKAT
26 -       return linkat(AT_FDCWD, old_path, AT_FDCWD, new_path, 0);
27 +       st = linkat(AT_FDCWD, old_path, AT_FDCWD, new_path, 0);
28  #else
29 -       return link(old_path, new_path);
30 +       st = link(old_path, new_path);
31  #endif
32 +       if (/*soften_links &&*/ st != 0 && errno == EXDEV)
33 +               st = symlink(old_path, new_path);
34 +       return st;
35  }
36  #endif
37