handle things more grecefully when one machine supports hard links and
authorAndrew Tridgell <tridge@samba.org>
Tue, 16 Dec 1997 23:09:22 +0000 (23:09 +0000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 16 Dec 1997 23:09:22 +0000 (23:09 +0000)
the other doesn't or one machine supports soft links and the other
doesn't.

flist.c
main.c
rsync.c
rsync.h

diff --git a/flist.c b/flist.c
index 8a99500..0cb8214 100644 (file)
--- 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 d289a58..ce5490a 100644 (file)
--- 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 c4a92d6..8d0f320 100644 (file)
--- 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 e5f73df..5759ef2 100644 (file)
--- a/rsync.h
+++ b/rsync.h
 #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