]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
m_offset: make self-test reliable with non-GNU yes(1)
authorMatthias Andree <matthias.andree@gmx.de>
Thu, 26 Jun 2025 20:28:40 +0000 (22:28 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 1 Jul 2025 14:32:24 +0000 (10:32 -0400)
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>
tests/m_offset/script

index d49e555e78d58b627f2cb9aa0cca9455cc402ab6..8b673ecb79280b4d6d4aa4c9717585e81d687d48 100755 (executable)
@@ -13,7 +13,7 @@ $MKE2FS -F -b 1024 -E offset=524288 "$TMPFILE" 1024 >> "$OUT" 2>&1
 # 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"`