#!/bin/sh
# root, guest-side. Reproduces the :248 panic in <=90 s on INVARIANTS kernels.
# (equivalent of df2763_run4.sh: two concurrent install/remove churn loops)
mkdir -p /tmp/jrace
t0=$(date +%s)
churn() {
  tag=$1; n=0
  while [ $(( $(date +%s) - t0 )) -lt 90 ]; do
    n=$((n+1))
    mountctl -a -w /root/jm_${tag}_$n.bin -o memfifo=64k /tmp:$tag >/dev/null 2>&1
    mountctl -d /tmp:$tag >/dev/null 2>&1
    rm -f /root/jm_${tag}_$n.bin
    sleep 0.05
  done
  echo "churn $tag cycles=$n"
}
churn c1 & churn c2 & wait
echo "UNEXPECTED: completed without panic"
# Optional extra pressure (runs 1/3 config): 3 unprivileged writers
# cc -O -o /tmp/df2763 df2763.c
# su -m nobody -c "/tmp/df2763 /tmp/jrace 105" & ... (x3)
