DragonFlyBSD Kernel Audit
DF-2605 / setup_image.sh
← back to finding ↓ download raw
#!/bin/sh
# setup_image.sh - Create a hammer2 filesystem image with enough entries
# to force an INDIRECT block in testdir's inode blockset.  Run as root
# in the guest.  Produces /root/h2.img.
set -e
IMG=/root/h2.img

rm -f "$IMG"
dd if=/dev/zero of="$IMG" bs=1m count=64 2>&1 | tail -1

vnconfig -c vn0 "$IMG"
newfs_hammer2 /dev/vn0 2>&1 | tail -2

mkdir -p /mnt/h2test
mount_hammer2 /dev/vn0@DATA /mnt/h2test

# Create testdir with enough entries that its inode's blockset spills
# into an INDIRECT block.
mkdir -p /mnt/h2test/testdir
for i in 1 2 3 4 5 6 7 8 9 10 11 12; do
    echo "file$i" > /mnt/h2test/testdir/file$i.txt
done
touch "/mnt/h2test/testdir/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.txt"

ls /mnt/h2test/testdir/
sync
umount /mnt/h2test
vnconfig -u vn0
ls -la "$IMG"
echo "SETUP_DONE"