#!/bin/sh
# DF-2074 build.sh -- HW-gated (Mylex DAC960/acceleRAID absent on guest).
# No userspace PoC to compile (the bug is in mlxd_strategy, reached only when
# an mlxd child is attached, which requires the Mylex adapter). This script
# instead validates the fix:
#   1. trace the cited source (mlx_disk.c:161) -- already done in VERDICT.md
#   2. apply fix.diff to /usr/src and build a single-fix kernel
#
# Run from the host (uses dfbsd-qemu/vm.sh):
set -eu
cd "$(dirname "$0")/../../.."   # repo root

scp -q -F dfbsd-qemu/config findings/poc/DF-2074/fix.diff dfbsd:/root/fix2074.diff
./dfbsd-qemu/vm.sh run_root 'cd /usr/src && patch -p1 --forward < /root/fix2074.diff || true'
echo "fix.diff pushed; see VERDICT.md for the validated build (combined kernel, rc=0 -Werror)."
