m_offset has been failing sporadically on FreeBSD, and always because
crc_exp(ected) was different from all other CRC values (which were
mutually equal, first1, first2, last).
The test scrsipt uses yes(1) to write into dd(1),
but FreeBSD's "yes a" use sizes of 8192 - length-of-pattern, meaning
8190 with "a\n" (meaning a + LF).
GNU yes from coreutils 9.1 instead dispatches 1024-sized writes.
The peculiar thing is that dd bs=1k count=512 will dispatch 512 read
attempts of 1 k each, but due to yes and dd running concurrently, dd
will sometimes see a short read block, resulting in an overall shorter
output file fed into crcsum, leading to a mismatched crc_exp value.
Fix: Add iflag=fullblock to ensure the proper output size will be fed
into crcsum, even if that means doing more than 512 reads internally.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Link: https://lore.kernel.org/r/20250626202919.321842-1-matthias.andree@gmx.de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
# compute crc of the first and last 512 1k blocks
crc_first2=`$DD if="$TMPFILE" bs=1k count=512 2>/dev/null | $CRCSUM`
crc_last2=`$DD if="$TMPFILE" bs=1k count=512 skip=1536 2>/dev/null | $CRCSUM`
-crc_exp=`yes a | $DD bs=1k count=512 2>/dev/null | $CRCSUM`
+crc_exp=`yes a | $DD bs=1k count=512 iflag=fullblock 2>/dev/null | $CRCSUM`
# a warning should be only emitted by the first mke2fs call
warning=`grep -c "offset specified without an explicit file system size." \
"$OUT"`