[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Thu Jun 11 23:14:21 UTC 2020


The branch, master has been updated
       via  c117fa4b Create a get_device_size() helper function.
      from  b040825b Improve the haproxy header docs.

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c117fa4bf9976f3e5e284b87a2304398e4428208
Author: Wayne Davison <wayne at opencoder.net>
Date:   Thu Jun 11 16:08:15 2020 -0700

    Create a get_device_size() helper function.

-----------------------------------------------------------------------

Summary of changes:
 flist.c    | 14 ++++++++++++++
 receiver.c | 15 ++-------------
 2 files changed, 16 insertions(+), 13 deletions(-)


Changeset truncated at 500 lines:

diff --git a/flist.c b/flist.c
index 82a5d6a7..dbb0f921 100644
--- a/flist.c
+++ b/flist.c
@@ -1420,6 +1420,20 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
 	return file;
 }
 
+OFF_T get_device_size(int fd, const char *fname)
+{
+	OFF_T off = lseek(fd, 0, SEEK_END);
+
+	if (off == (OFF_T) -1) {
+		rsyserr(FERROR, errno, "failed to get device size via seek: %s", fname);
+		return 0;
+	}
+	if (lseek(fd, 0, SEEK_SET) != 0)
+		rsyserr(FERROR, errno, "failed to seek device back to start: %s", fname);
+
+	return off;
+}
+
 /* Only called for temporary file_struct entries created by make_file(). */
 void unmake_file(struct file_struct *file)
 {
diff --git a/receiver.c b/receiver.c
index e95f1786..8655e315 100644
--- a/receiver.c
+++ b/receiver.c
@@ -804,19 +804,8 @@ int recv_files(int f_in, int f_out, char *local_name)
 			fd1 = -1;
 		}
 
-		/* On Linux systems (at least), st_size is typically 0 for devices.
-		 * If so, try to determine the actual device size. */
-		if (fd1 != -1 && IS_DEVICE(st.st_mode) && st.st_size == 0) {
-			OFF_T off = lseek(fd1, 0, SEEK_END);
-			if (off == (OFF_T) -1)
-				rsyserr(FERROR, errno, "failed to seek to end of %s to determine size", fname);
-			else {
-				st.st_size = off;
-				off = lseek(fd1, 0, SEEK_SET);
-				if (off != 0)
-					rsyserr(FERROR, errno, "failed to seek back to beginning of %s to read it", fname);
-			}
-		}
+		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. */


-- 
The rsync repository.



More information about the rsync-cvs mailing list