#!/bin/sh
# DF-3076 one-time setup (guest, root): make the base image.
# The target file is SPARSE: a single 1K write at offset 1MB, so its
# single DATA record has key=0x100400 and the delete-range scan starts
# with ran_beg=0 -- a crafted data_len up to 0x100400 passes the
# left-edge assert (key-data_len >= 0) and still exceeds the
# HAMMER_XBUFSIZE bound at hammer_blockmap.c:786.
set -e
dd if=/dev/zero of=/root/base.img bs=1m count=0 seek=12000
vnconfig -c vn0 /root/base.img
newfs_hammer -L df3076 -f /dev/vn0
mount_hammer -o nohistory /dev/vn0 /mnt
chmod 777 /mnt
dd if=/dev/urandom of=/mnt/target.bin bs=1k count=1 seek=1024 2>/dev/null
sync
umount /mnt
vnconfig -u vn0
echo SETUP_OK
