A few more minor doc tweaks.
[rsync.git] / sender.c
index 94761c2624f1ba62c65d316b5854a3c76945b828..9159da4db80ac598b50dda7ea76178624200b832 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-2020 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
@@ -35,7 +35,9 @@ extern int append_mode;
 extern int copy_links;
 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;
@@ -204,6 +206,9 @@ void send_files(int f_in, int f_out)
        if (DEBUG_GTE(SEND, 1))
                rprintf(FINFO, "send_files starting\n");
 
+       if (whole_file < 0)
+               whole_file = 0;
+
        progress_init();
 
        while (1) {
@@ -362,6 +367,25 @@ 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));
+                       free_sums(s);
+                       close(fd);
+                       if (protocol_version >= 30)
+                               send_msg_int(MSG_NO_SEND, ndx);
+                       continue;
+               }
+
                if (st.st_size) {
                        int32 read_size = MAX(s->blength * 3, MAX_MAP_SIZE);
                        mbuf = map_file(fd, st.st_size, read_size, s->blength);