⬢ DragonFlyBSD Kernel Audit
DF-5798 / stress.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-5798 stress driver (run as root on the guest)
set -x
kldstat | grep tmpfs || kldload tmpfs
mkdir -p /mnt/df5798
cc -O -o /tmp/reexec /tmp/reexec.c || exit 1
MNT=/mnt/df5798
ROUND=0
while [ $ROUND -lt 6 ]; do
  ROUND=$((ROUND+1))
  mount | grep -q " $MNT " || mount -t tmpfs tmpfs $MNT || continue
  cp /tmp/reexec $MNT/reexec
  chmod 755 $MNT/reexec
  # busy holder: respawn a cd-inside process so umount -f must iterate
  ( while :; do ( cd $MNT && exec sleep 600 ) & sleep 0.05; done ) &
  HOLDER=$!
  # exec hammers
  I=0
  while [ $I -lt 8 ]; do
    ( N=0; while [ $N -lt 400 ]; do $MNT/reexec 2000 >/dev/null 2>&1; N=$((N+1)); done ) &
    I=$((I+1))
  done
  # umount -f hammer
  J=0
  while [ $J -lt 10 ]; do
    umount -f $MNT >/dev/null 2>&1
    J=$((J+1))
  done
  kill $HOLDER 2>/dev/null
  pkill -9 -f 'df5798/reexec' 2>/dev/null
  umount -f $MNT >/dev/null 2>&1
  sleep 1
done
echo STRESS-DONE
mount | grep df5798 || echo "mount cleaned up"