Bug 2116 - rsync ignores write error
Summary: rsync ignores write error
Status: CLOSED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 2.6.3
Hardware: All Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-02 09:49 UTC by Jim Meyering
Modified: 2005-04-01 11:22 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Meyering 2004-12-02 09:49:25 UTC
rsync-2.6.3 can fail to report a write error.
Here's a demonstration, writing to a full partition:

You can reproduce it like this:

  $ echo foo > in
  $ strace -f -o log rsync in /full/tmp
  $ grep 'write.*ENOSP' log
  4787  write(1, "foo\n", 4)              = -1 ENOSPC (No space left on device)
  $ rsync --version|head -n1
  rsync  version 2.6.3  protocol version 28

The cause seems to be this unchecked flush_write_file call:

Index: receiver.c
===================================================================
RCS file: /cvsroot/rsync/receiver.c,v
retrieving revision 1.110
diff -u -p -r1.110 receiver.c
--- receiver.c	27 Nov 2004 17:56:58 -0000	1.110
+++ receiver.c	2 Dec 2004 16:40:23 -0000
@@ -289,7 +289,8 @@ static int receive_data(int f_in, char *
 		offset += len;
 	}

-	flush_write_file(fd);
+	if (flush_write_file(fd) < 0)
+		goto report_write_error;

 #ifdef HAVE_FTRUNCATE
 	if (inplace && fd != -1)

The above patch is relative to the latest CVS sources on the trunk.
With the above knee-jerk patch, I do get the write error I want,
but also some other probably undesirable diagnostics:

  $ ./rsync in /full/tmp
  rsync: write failed on "/full/tmp/in": No space left on device (28)
  rsync error: error in file IO (code 11) at receiver.c(307)
  rsync: connection unexpectedly closed (25 bytes received so far) [generator]
  rsync error: error in rsync protocol data stream (code 12) at io.c(362)
  rsync: connection unexpectedly closed (32 bytes received so far) [sender]
  rsync error: error in rsync protocol data stream (code 12) at io.c(362)
  [Exit 12]
Comment 1 Wayne Davison 2004-12-14 11:05:24 UTC
I checked-in this fix back on December 2nd, but neglected to close this bug at
that time.  So, this is now fixed in CVS.

Thanks for the report!