[prev in list] [next in list] [prev in thread] [next in thread]
List: coreutils
Subject: [PATCH] dd: don't discard data with if=fullblock
From: Pádraig Brady <P () draigBrady ! com>
Date: 2011-02-28 9:28:59
Message-ID: 4D6B6ADB.1080009 () draigBrady ! com
[Download RAW message or body]
I just noticed that dd may discard read data
in the presence of I/O errors.
Would something like this suffice?
cheers,
Pádraig.
diff --git a/src/dd.c b/src/dd.c
index 1a0e177..a1d47ff 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -811,12 +811,28 @@ static ssize_t
iread_fullblock (int fd, char *buf, size_t size)
{
ssize_t nread = 0;
+ static iread_errno;
+
+ /* Return a pending error. */
+ if (iread_errno)
+ {
+ errno = iread_errno;
+ iread_errno = 0;
+ return -1;
+ }
while (0 < size)
{
ssize_t ncurr = iread (fd, buf, size);
if (ncurr < 0)
- return ncurr;
+ {
+ if (nread > 0)
+ {
+ iread_errno = errno;
+ ncurr = nread;
+ }
+ return ncurr;
+ }
if (ncurr == 0)
break;
nread += ncurr;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic