#!/bin/sh
# DF-2618: build the base image.  PFS "testvol" with exactly 4 files (a,b,c,d)
# so the PFS root directory inode's DIRECT blockset (8 slots at inode+0x200)
# holds 4 INODE brefs (keyed by inum) + 4 DIRENT brefs (keyed by name hash)
# with NO indirect blocks.  Stock, never-corrupted (also used as control).
set -e
vnconfig -u vn0 2>/dev/null || true
mkdir -p /root/poc/df2618
cd /root/poc/df2618
rm -f base2618.img
truncate -s 64M base2618.img
newfs_hammer2 -L testvol base2618.img >/dev/null
vnconfig -c vn0 /root/poc/df2618/base2618.img
mkdir -p /mnt/h2
mount -t hammer2 /dev/vn0@testvol /mnt/h2
printf "DF2618BASE-a" > /mnt/h2/a
printf "DF2618BASE-b" > /mnt/h2/b
printf "DF2618BASE-c" > /mnt/h2/c
printf "DF2618BASE-d" > /mnt/h2/d
ls /mnt/h2
sync
umount /mnt/h2
vnconfig -u vn0
echo BASE2618_OK
