#!/bin/sh
# DF-0822 run script — demonstrates the bug on the UNPATCHED kernel.
# Expected on GENERIC (INVARIANTS ON): kernel PANIC at hammer2_freemap.c:980
#   "assertion radix <= HAMMER2_RADIX_MAX failed"
# (On a production/no-INVARIANTS kernel: sustained CPU-burn instead of panic.)
#
# The harness calls the real exported hammer2_freemap_adjust() with an
# on-disk radix value of 30 (and 44), simulating a crafted HAMMER2 image
# whose blockref data_off carries an out-of-range radix.
set -e
cd "$(dirname "$0")"

echo "=== loading h2adj.ko (calls hammer2_freemap_adjust w/ radix 16,30,44) ==="
echo "=== EXPECT: panic at KKASSERT(radix<=HAMMER2_RADIX_MAX) on 2nd call ==="
kldload ./h2adj.ko
echo "KLDLOAD_RC=$?"
