diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-10 10:58:55 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-10 10:58:55 +0100 |
commit | 5afd63a631f49112ac305ea1532dd226e9c39d12 (patch) | |
tree | a784d6c135a15acc44dad94539820fae054e51d9 /coreutils | |
parent | d1df1a709f05a737d2477a08eea8c743e83f8f8f (diff) | |
download | busybox-w32-5afd63a631f49112ac305ea1532dd226e9c39d12.tar.gz busybox-w32-5afd63a631f49112ac305ea1532dd226e9c39d12.tar.bz2 busybox-w32-5afd63a631f49112ac305ea1532dd226e9c39d12.zip |
dd: exit with 1 if last write was incomplete
$ busybox dd if=/dev/zero of=/dev/loop0 bs=100M count=8; echo $?
8+0 records in
7+1 records out
805220352 bytes (767.9MB) copied, 0.464010 seconds, 1.6GB/s
1 <=========== FIXED
function old new delta
write_and_stats 96 97 +1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/dd.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c index d302f35d3..9d173cc13 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -195,14 +195,16 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs, | |||
195 | ssize_t n = full_write_or_warn(buf, len, filename); | 195 | ssize_t n = full_write_or_warn(buf, len, filename); |
196 | if (n < 0) | 196 | if (n < 0) |
197 | return 1; | 197 | return 1; |
198 | if ((size_t)n == obs) | ||
199 | G.out_full++; | ||
200 | else if (n) /* > 0 */ | ||
201 | G.out_part++; | ||
202 | #if ENABLE_FEATURE_DD_THIRD_STATUS_LINE | 198 | #if ENABLE_FEATURE_DD_THIRD_STATUS_LINE |
203 | G.total_bytes += n; | 199 | G.total_bytes += n; |
204 | #endif | 200 | #endif |
205 | return 0; | 201 | if ((size_t)n == obs) { |
202 | G.out_full++; | ||
203 | return 0; | ||
204 | } | ||
205 | if (n) /* > 0 */ | ||
206 | G.out_part++; | ||
207 | return 1; | ||
206 | } | 208 | } |
207 | 209 | ||
208 | #if ENABLE_LFS | 210 | #if ENABLE_LFS |