#!/bin/sh
# build.sh — exact build commands for DF-0841.
set -e
cd "$(dirname "$0")"

# Primary artifact: trace.c — a deterministic userspace harness that
# demonstrates the NULL-deref arithmetic of the bug (VTODE(*vpp=NULL) reads
# address 0x128 in the unmapped zero page).  No kernel involvement.
echo "[*] building trace (userspace harness)"
cc -O2 -o trace trace.c
echo "[+] trace built"

# (Optional) live in-guest trigger — requires root inside the guest and the
# msdosfs/nfs server stack.  See trigger_nfs.sh and README.md.
if [ "$(id -u)" = "0" ] && [ -f /etc/rc.d/nfsd ]; then
    echo "[*] root on DragonFly detected: trigger_nfs.sh is available"
    echo "    run it manually:  sh trigger_nfs.sh"
fi
