⬢ DragonFlyBSD Kernel Audit
DF-5836 / build_image.sh
← back to finding ↓ download raw
#!/bin/sh
# Run as root INSIDE the DragonFly guest (clean boot).
# Builds a pristine 2GB hammer2 image with origfile at inum 1024
# (HAMMER2_INODE_START), then unmounts. The crafted copy is produced
# on the audit host by craft_image.py and pushed back as /root/h2c.img.
set -e
umount /mnt/h2 2>/dev/null || true
vnconfig -u vn0 2>/dev/null || true
mkdir -p /mnt/h2
rm -f /root/h2.img
truncate -s 2147483648 /root/h2.img
vnconfig -c -S -T vn0 /root/h2.img
newfs_hammer2 -L TESTFS /dev/vn0 >/dev/null 2>&1
mount -t hammer2 /dev/vn0@TESTFS /mnt/h2
echo hello-original-file > /mnt/h2/origfile
mkdir /mnt/h2/subdir
sync
stat -f "inum=%i mode=%Sp %N" /mnt/h2/origfile /mnt/h2/subdir
sync
umount /mnt/h2
vnconfig -u vn0