Add iflag=fullblock to dd

rust-coreutils’ dd implementation tends to perform partial writes, which
leads to partial reads and data loss as a result. Strictly speaking,
without the fullblock option there is no guarantee that full blocks will
be read. Even with GNU dd, partial reads and writes can occur, although
they hardly ever happen.
This commit is contained in:
Andrus Suvalau
2026-01-12 11:58:57 +01:00
committed by Stéphane Peter
parent 6ae1785292
commit bd86bf68e0
+3 -3
View File
@@ -105,10 +105,10 @@ MS_dd()
{
blocks=\`expr \$3 / 1024\`
bytes=\`expr \$3 % 1024\`
# Test for ibs, obs and conv feature
if dd if=/dev/zero of=/dev/null count=1 ibs=512 obs=512 conv=sync 2> /dev/null; then
# Test for ibs, obs, fullblock and conv feature
if dd if=/dev/zero of=/dev/null count=1 ibs=512 obs=512 iflag=fullblock conv=sync 2> /dev/null; then
dd if="\$1" ibs=\$2 skip=1 obs=1024 conv=sync 2> /dev/null | \\
{ test \$blocks -gt 0 && dd ibs=1024 obs=1024 count=\$blocks ; \\
{ test \$blocks -gt 0 && dd ibs=1024 iflag=fullblock obs=1024 count=\$blocks ; \\
test \$bytes -gt 0 && dd ibs=1 obs=1024 count=\$bytes ; } 2> /dev/null
else
dd if="\$1" bs=\$2 skip=1 2> /dev/null