#!/bin/sh
# DF-3083 fix-run (guest, PATCHED kernel): same mangled image, RW mount.
# Expected: lookup that walks into the mangled entry returns ENOENT (or
# finds nothing) WITHOUT panicking; console shows the ext2_dirbad printf;
# guest stays up.
set -e
kldload ext2fs 2>/dev/null || true
/root/vntool detach 0 2>/dev/null || true
/root/vntool attach 0 /root/mangle.img
mkdir -p /mnt/e2
mount -t ext2fs /dev/vn0 /mnt/e2
stat /mnt/e2/d/file4 >/dev/null 2>&1 || echo "stat file4 rc=$? (ENOENT expected, NO panic)"
stat /mnt/e2/d/file1  >/dev/null 2>&1 && echo "stat file1 ok"
dmesg | tail -3
echo "FIX-OK: RW mount survived mangled-entry lookup"
