Skip to content

Commit

Permalink
fix for trailing data bug
Browse files Browse the repository at this point in the history
When the size of the last extent is a multiple of the number of
sectors, bs=0 is passed to dd, which does not accept that.

I think this fixes that. I'm not sure why that didn't show up in
testing before, though, unless older versions of dd accept bs=0.
  • Loading branch information
EliahKagan committed Oct 25, 2020
1 parent d388039 commit 5912d5d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stitch
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ declare -ri trailing_bytes="$((last_used_bytes % sector_size))"
declare -ri last_full_bytes="$((last_used_bytes - trailing_bytes))"
((last_full_bytes == last_full_sectors * sector_size)) ||
bug 'last_full_bytes disagrees with last_full_sectors'
dd bs="$trailing_bytes" count=1 "${dd_opts[@]}" <&3 ||
((trailing_bytes == 0)) || # Special-case this, as dd does not accept bs=0.
dd bs="$trailing_bytes" count=1 "${dd_opts[@]}" <&3 ||
die "can't read $trailing_bytes bytes at $last_full_bytes bytes (end)"

exec 3<&- || die "can't close device node for disk $dev_major:0"
Expand Down

0 comments on commit 5912d5d

Please sign in to comment.