Page MenuHomeFreeBSD

Add iflag=fullblock to dd

Authored by freqlabs on Aug 27 2019, 6:25 PM.



Normally, count=n means read(2) will be called n times on the input to dd. If the read() returns short, as may happen when reading from a pipe, fewer bytes will be copied from the input. With conv=sync the buffer is padded with zeros to fill the rest of the block.

iflag=fullblock causes dd to continue reading until the block is full, so that count=n means n full blocks are copied. This flag is compatible with illumos and GNU dd and is used in the ZFS test suite.

Sponsored by: iXsystems, Inc.

Test Plan
# Notice a varying number of partial reads being padded:
dd if=/var/log/messages bs=8 | dd bs=64 conv=sync | hexdump | fgrep '*' | wc -l
# 634
# 658
# 623
# ...
# Notice 0 partial reads:
dd if=/var/log/messages bs=8 | dd bs=64 iflag=fullblock | hexdump | fgrep '*' | wc -l
# 0
# 0
# 0
# ...

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Make conv=sync and iflag=fullblock mutually exclusive rather than silently ignoring the iflag.

Can you run textproc/igor and "mandoc -Tlint" over your man page? It should give you some warnings/hints on how to fix a few things in there, nothing major.

111 ↗(On Diff #61892)

A line break is needed after a sentence stop.

Fixed man page additions. Thanks, @bcr!

Delete redundant setting of in.dbsz in error case.

This revision is now accepted and ready to land.Sep 30 2019, 9:58 PM
This revision was automatically updated to reflect the committed changes.