From cbbe4892087b74fb8ed2aac6078ee933ac02e920 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Dec 1997 23:09:22 +0000 Subject: [PATCH] handle things more grecefully when one machine supports hard links and the other doesn't or one machine supports soft links and the other doesn't. --- flist.c | 2 -- main.c | 12 ++++++++++-- rsync.c | 4 ++-- rsync.h | 9 ++++----- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/flist.c b/flist.c index 8a995000..0cb82144 100644 --- a/flist.c +++ b/flist.c @@ -203,7 +203,6 @@ 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); @@ -211,7 +210,6 @@ void receive_file_entry_v11(struct file_struct *file, read_buf(f,file->link,l); file->link[l] = 0; } -#endif #if SUPPORT_HARD_LINKS if (preserve_hard_links && S_ISREG(file->mode)) { diff --git a/main.c b/main.c index d289a58a..ce5490ac 100644 --- a/main.c +++ b/main.c @@ -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; @@ -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); diff --git a/rsync.c b/rsync.c index c4a92d69..8d0f3207 100644 --- a/rsync.c +++ b/rsync.c @@ -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) { @@ -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)) { diff --git a/rsync.h b/rsync.h index e5f73dff..5759ef28 100644 --- a/rsync.h +++ b/rsync.h @@ -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) @@ -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 -- 2.34.1