Skip to content

Commit

Permalink
handle things more grecefully when one machine supports hard links and
Browse files Browse the repository at this point in the history
the other doesn't or one machine supports soft links and the other
doesn't.
  • Loading branch information
Andrew Tridgell committed Dec 16, 1997
1 parent 6dd1782 commit cbbe489
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 0 additions & 2 deletions flist.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,13 @@ void receive_file_entry_v11(struct file_struct *file,
if (preserve_devices && IS_DEVICE(file->mode))
file->rdev = (flags & SAME_RDEV) ? last_rdev : (dev_t)read_int(f);

#if SUPPORT_LINKS
if (preserve_links && S_ISLNK(file->mode)) {
int l = read_int(f);
file->link = (char *)malloc(l+1);
if (!file->link) out_of_memory("receive_file_entry 2");
read_buf(f,file->link,l);
file->link[l] = 0;
}
#endif

#if SUPPORT_HARD_LINKS
if (preserve_hard_links && S_ISREG(file->mode)) {
Expand Down
12 changes: 10 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,15 @@ int main(int argc,char *argv[])
break;

case 'l':
#if SUPPORT_LINKS
preserve_links=1;
#endif
break;

case 'H':
#if SUPPORT_HARD_LINKS
preserve_hard_links=1;
#else
fprintf(FERROR,"ERROR: hard links not supported on this platform\n");
exit_cleanup(1);
#endif
break;

Expand Down Expand Up @@ -657,6 +658,13 @@ int main(int argc,char *argv[])
if (dry_run)
verbose = MAX(verbose,1);

#ifndef SUPPORT_LINKS
if (!am_server && preserve_links) {
fprintf(FERROR,"ERROR: symbolic links not supported\n");
exit_cleanup(1);
}
#endif

if (am_server) {
setup_protocol(STDOUT_FILENO,STDIN_FILENO);

Expand Down
4 changes: 2 additions & 2 deletions rsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
return;
}

#if SUPPORT_LINKS
if (preserve_links && S_ISLNK(file->mode)) {
#if SUPPORT_LINKS
char lnk[MAXPATHLEN];
int l;
if (statret == 0) {
Expand All @@ -312,9 +312,9 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
fprintf(FINFO,"%s -> %s\n",
fname,file->link);
}
#endif
return;
}
#endif

#ifdef HAVE_MKNOD
if (am_root && preserve_devices && IS_DEVICE(file->mode)) {
Expand Down
9 changes: 4 additions & 5 deletions rsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@
#include "lib/getopt.h"
#endif

#ifndef S_IFLNK
#define S_IFLNK 0120000
#endif

#ifndef S_ISLNK
#define S_ISLNK(mode) (((mode) & S_IFLNK) == S_IFLNK)
Expand Down Expand Up @@ -287,13 +290,9 @@ extern int errno;
#define bzero(buf,n) memset(buf,0,n)
#endif

#define SUPPORT_LINKS (HAVE_READLINK && defined(S_ISLNK))
#define SUPPORT_LINKS HAVE_READLINK
#define SUPPORT_HARD_LINKS HAVE_LINK

#ifndef S_ISLNK
#define S_ISLNK(x) 0
#endif

#if !SUPPORT_LINKS
#define lstat stat
#endif
Expand Down

0 comments on commit cbbe489

Please sign in to comment.