summaryrefslogtreecommitdiff
path: root/receiver.c
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2022-03-27 12:26:39 -0700
committerWayne Davison <wayne@opencoder.net>2022-03-27 12:52:26 -0700
commit8977815f5d70d1b6747837b41e7e0b5bd672ef01 (patch)
treeadd05cd3b2852ce7c59c413c3b576afc0389611f /receiver.c
parenta48c20c97c151e297d79327912e5c294450c342b (diff)
downloadrsync-8977815f5d70d1b6747837b41e7e0b5bd672ef01.tar.gz
Some `--write-device` fixes.
Diffstat (limited to 'receiver.c')
-rw-r--r--receiver.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/receiver.c b/receiver.c
index 90e1685b..b3a69da0 100644
--- a/receiver.c
+++ b/receiver.c
@@ -808,14 +808,16 @@ int recv_files(int f_in, int f_out, char *local_name)
continue;
}
- if (fd1 != -1 && !(S_ISREG(st.st_mode) || (write_devices && IS_DEVICE(st.st_mode)))) {
+ if (write_devices && IS_DEVICE(st.st_mode)) {
+ if (fd1 != -1 && st.st_size == 0)
+ st.st_size = get_device_size(fd1, fname);
+ /* Mark the file entry as a device so that we don't try to truncate it later on. */
+ file->mode = S_IFBLK | (file->mode & ACCESSPERMS);
+ } else if (fd1 != -1 && !(S_ISREG(st.st_mode))) {
close(fd1);
fd1 = -1;
}
- if (fd1 != -1 && IS_DEVICE(st.st_mode) && st.st_size == 0)
- st.st_size = get_device_size(fd1, fname);
-
/* If we're not preserving permissions, change the file-list's
* mode based on the local permissions and some heuristics. */
if (!preserve_perms) {