FDD-book/examples/part-05/ch25-advanced/lab03-tunable-reboot/apply_tunable.sh
Edson Brandi 6e6dac94fe Add book companion files under examples/
Organize companion code and materials by book part:

  part-01/      Foundations
  part-02/      Kernel & driver fundamentals
  part-03/      Character & block devices
  part-04/      Networking & storage
  part-05/      Buses & advanced topics
  part-06/      Debugging & performance
  part-07/      Real-world drivers
  appendices/   Supplementary material
  README.md     Overview and build instructions
2026-04-25 16:51:00 +00:00

33 lines
831 B
Bash
Executable file

#!/bin/sh
#
# apply_tunable.sh - helper for Lab 3.
#
# Unloads myfirst, sets the tunable via kenv(1), reloads, and prints
# the resulting initial sysctl value. Compare with and without the
# tunable set to see that TUNABLE_INT_FETCH actually overrides the
# attach-time default.
set -e
TUNABLE="${1:-hw.myfirst.timeout_sec}"
VALUE="${2:-12}"
KMOD="${3:-../myfirst.ko}"
SYSCTL="dev.myfirst.0.${TUNABLE#hw.myfirst.}"
echo "== Step 1: unload any existing myfirst instance"
kldunload myfirst 2>/dev/null || true
echo "== Step 2: set ${TUNABLE} = ${VALUE} via kenv(1)"
kenv "${TUNABLE}=${VALUE}"
echo "== Step 3: load ${KMOD}"
kldload "${KMOD}"
echo "== Step 4: observe the initial sysctl value"
sysctl "${SYSCTL}"
echo
echo "To reset, run:"
echo " kldunload myfirst"
echo " kenv -u ${TUNABLE}"
echo " kldload ${KMOD}"