Page MenuHomeFreeBSD

Add iflag=fullblock to dd
ClosedPublic

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

Details

Summary

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

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
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.

bcr added a subscriber: bcr.Sep 15 2019, 10:32 AM

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.

bin/dd/dd.1
111 ↗(On Diff #61892)

A line break is needed after a sentence stop.

Fixed man page additions. Thanks, @bcr!

ryan_freqlabs.com marked an inline comment as done.Sep 16 2019, 1:10 PM

Delete redundant setting of in.dbsz in error case.

bcr accepted this revision as: manpages.Sep 16 2019, 1:47 PM

OK from manpages.

mmacy accepted this revision.Sep 30 2019, 9:58 PM
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.