⬢ DragonFlyBSD Kernel Audit
DF-4349 / build_fixed.sh
← back to finding ↓ download raw
#!/bin/sh
# Apply fixes and build a patched kernel (run in guest as root).
# Usage: sh build_fixed.sh [4349|4350|both|none]
set -e
MODE="${1:-both}"
cd /usr/src
F=sys/dev/disk/advansys/advansys.c
# keep a pristine master; always start clean (no interactive prompts)
if [ ! -f $F.pristine ]; then cp $F $F.pristine; fi
cp $F.pristine $F
case "$MODE" in
  4349) patch -p1 -N < /root/fixes/df4349.diff ;;
  4350) patch -p1 -N < /root/fixes/df4350.diff ;;
  both) patch -p1 -N < /root/fixes/df4349.diff
        patch -p1 -N < /root/fixes/df4350.diff ;;
  none) ;;
esac
echo "=== patch state: $MODE ==="
grep -n "DF-4349: ccb_index is\|DF-4350: loop termination\|M_ZERO" $F | head -5
if [ "$MODE" = both ] && [ "$(grep -c 'DF-4349: ccb_index is\|DF-4350: loop termination' $F)" != 2 ]; then
	echo "PATCH STATE WRONG - aborting"; exit 1
fi
echo "=== building X86_64_GENERIC (nativekernel) ==="
make -j6 nativekernel KERNCONF=X86_64_GENERIC > /root/fix_build.log 2>&1
tail -3 /root/fix_build.log
make installkernel KERNCONF=X86_64_GENERIC > /root/fix_install.log 2>&1
tail -2 /root/fix_install.log
echo "BUILD_OK mode=$MODE - reboot into the fixed kernel"