On Mon, Feb 14, 2022 at 04:09:56PM -0800, Boris Burkov wrote: > generic/574 has tests for corrupting the merkle tree data stored by the > filesystem. Since btrfs uses a different scheme for storing this data, > the existing logic for corrupting it doesn't work out of the box. Adapt > it to properly corrupt btrfs merkle items. > > This test relies on the btrfs implementation of fsverity in the patch: > btrfs: initial fsverity support > > and on btrfs-corrupt-block for corruption in the patches titled: > btrfs-progs: corrupt generic item data with btrfs-corrupt-block > btrfs-progs: expand corrupt_file_extent in btrfs-corrupt-block > > Signed-off-by: Boris Burkov <boris@xxxxxx> > --- > common/verity | 18 ++++++++++++++++++ > tests/generic/574 | 1 + > 2 files changed, 19 insertions(+) > > diff --git a/common/verity b/common/verity > index eec8ae72..07d9d3fe 100644 > --- a/common/verity > +++ b/common/verity > @@ -322,6 +322,24 @@ _fsv_scratch_corrupt_merkle_tree() > (( offset += ($(_get_filesize $file) + 65535) & ~65535 )) > _fsv_scratch_corrupt_bytes $file $offset > ;; > + btrfs) > + local ino=$(stat -c '%i' $file) > + _scratch_unmount > + local byte="" > + while read -n 1 byte; do > + if [ -z $byte ]; then > + break > + fi '[ -z $byte ]' could use quotes around $byte. But isn't that check unneeded at all, given that 'read' will fail when EOF is reached? - Eric