Created without the 64bit feature with:
truncate -s 1M simple_ext4.imgmkfs.ext4 simple_ext4.img -O ^64bitsudo mkdir /mnt/tmpsudo mount -oloop simple_ext4.img /mnt/tmpsudo cp hello_world.txt /mnt/tmp/sudo umount /mnt/tmpe2fsck -f simple_ext4.imgresize2fs -M simple_ext4.img (counting number of reported blocks)truncate -o --size NN simple_ext4.img (where NN=number of blocks above)The DM_TABLE_LOAD ioctl for dm-verity requires the user to pass in a hashtree file that contains a merkle tree that is generated from the contents of the ext4 image. The following commands allow us to make use of the losetup and veritysetup command line tools to both generate the hashtree file.
sudo losetup -f src/starnix/tests/syscalls/rust/data/simple_ext4.imgsudo dd if=/dev/zero bs=4k conv=notrunc oflag=append count=2 of=/tmp/hashtreeNOTE: count here is the number of blocks that we need to store the merkle tree. Can be adjusted for larger ext4 images.
sudo losetup -f /tmp/hashtreesudo losetup -a
e.g.
/dev/loop19: (/usr/local/google/home/nikitajindal/fuchsia/src/starnix/tests/syscalls/rust/data/simple_ext4.img)
/dev/loop20: (/tmp/hashtree)
veritysetup format to generate the merkle tree and populate the hashtree file with it. Note that veritysetup format takes several optional arguments. Here we just set the salt. The format command will print out the root hash of the merkle tree. The root hash is copied into data/root_hash.txt.sudo veritysetup format /dev/loop19 /dev/loop20 --salt ffffffffffffffffdd if=/tmp/hashtree of=src/starnix/tests/syscalls/rust/data/hashtree_truncated.txt bs=1 skip=4096