#!/bin/sh
# DF-5785 (guest, root): control mount of base.img, then mount of craftA.img
# whose f1 DIRENT bref type byte is 0xAA (unknown).
# EXPECT: kernel panic "hammer2_chain_alloc: unrecognized blockref type: 170"
# on the first directory read (ls) of the crafted mount.
D=/root/poc/df5784
vnconfig -u vn0 2>/dev/null || true
echo "=== DF-5785 control: base.img ==="
vnconfig -c vn0 $D/base.img
mount -o ro -t hammer2 /dev/vn0@testvol /mnt/h2x || echo "MOUNT FAILED rc=$?"
ls -l /mnt/h2x; echo "control ls rc=$?"
umount /mnt/h2x; vnconfig -u vn0
echo "=== DF-5785 crafted: craftA.img (bref type 0xAA) ==="
vnconfig -c vn0 $D/craftA.img
mount -o ro -t hammer2 /dev/vn0@testvol /mnt/h2x || echo "MOUNT FAILED rc=$?"
echo "mounted ok; issuing ls (expect panic)..."
ls -l /mnt/h2x
echo "SURVIVED_LS rc=$?"
stat -t /mnt/h2x/f1 >/dev/null 2>&1
echo "SURVIVED_STAT rc=$?"
umount /mnt/h2x; vnconfig -u vn0
echo DF5785_DONE
