Include "buildall" flag in the release commit.
[rsync.git] / sender.c
index 837a83bd3d0009b2714aa3d604842a6c3d6dfe8f..3d4f052e9bdbeaf7e41a39315907bddcbe69ed15 100644 (file)
--- a/sender.c
+++ b/sender.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 1996 Andrew Tridgell
  * Copyright (C) 1996 Paul Mackerras
- * Copyright (C) 2003-2021 Wayne Davison
+ * Copyright (C) 2003-2022 Wayne Davison
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 extern int do_xfers;
 extern int am_server;
 extern int am_daemon;
+extern int local_server;
 extern int inc_recurse;
 extern int log_before_transfer;
 extern int stdout_format_has_i;
@@ -37,6 +38,7 @@ extern int io_error;
 extern int flist_eof;
 extern int whole_file;
 extern int allowed_lull;
+extern int copy_devices;
 extern int preserve_xattrs;
 extern int protocol_version;
 extern int remove_source_files;
@@ -50,6 +52,7 @@ extern int file_old_total;
 extern BOOL want_progress_now;
 extern struct stats stats;
 extern struct file_list *cur_flist, *first_flist, *dir_flist;
+extern char num_dev_ino_buf[4 + 8 + 8];
 
 BOOL extra_flist_sending_enabled;
 
@@ -143,6 +146,13 @@ void successful_send(int ndx)
                goto failed;
        }
 
+       if (local_server
+        && (int64)st.st_dev == IVAL64(num_dev_ino_buf, 4)
+        && (int64)st.st_ino == IVAL64(num_dev_ino_buf, 4 + 8)) {
+               rprintf(FERROR_XFER, "ERROR: Skipping sender remove of destination file: %s\n", fname);
+               return;
+       }
+
        if (st.st_size != F_LENGTH(file) || st.st_mtime != file->modtime
 #ifdef ST_MTIME_NSEC
         || (NSEC_BUMP(file) && (uint32)st.ST_MTIME_NSEC != F_MOD_NSEC(file))
@@ -366,6 +376,15 @@ void send_files(int f_in, int f_out)
                        exit_cleanup(RERR_FILEIO);
                }
 
+               if (IS_DEVICE(st.st_mode)) {
+                       if (!copy_devices) {
+                               rprintf(FERROR, "attempt to copy device contents without --copy-devices\n");
+                               exit_cleanup(RERR_PROTOCOL);
+                       }
+                       if (st.st_size == 0)
+                               st.st_size = get_device_size(fd, fname);
+               }
+
                if (append_mode > 0 && st.st_size < F_LENGTH(file)) {
                        rprintf(FWARNING, "skipped diminished file: %s\n",
                                full_fname(fname));