Browse Source

dd: fixed partial count logic

$ busybox dd if=/dev/zero of=/dev/loop0 bs=100M count=8; echo $?
8+0 records in
7+0 records out  <=========== FIXED, was 7+1
805220352 bytes (767.9MB) copied, 0.464010 seconds, 1.6GB/s
1

function                                             old     new   delta
write_and_stats                                       97      99      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko 6 years ago
parent
commit
2c876774a9
1 changed files with 3 additions and 1 deletions
  1. 3 1
      coreutils/dd.c

+ 3 - 1
coreutils/dd.c

@@ -202,8 +202,10 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
 		G.out_full++;
 		return 0;
 	}
-	if (n) /* > 0 */
+	if ((size_t)n == len) {
 		G.out_part++;
+		return 0;
+	}
 	return 1;
 }