#!/bin/sh
# revive/waitlist UAF racer: loops revive over vol.p1.s0 while writers hammer
ROUND=0
while [ $ROUND -lt 8 ]; do
  ROUND=$((ROUND+1))
  vinum setstate stale vol.p1.s0 >/dev/null 2>&1
  vinum start -S 4096 vol.p1.s0 >/dev/null 2>&1
  # wait until the sd is up again (revive complete)
  n=0
  while [ $n -lt 120 ]; do
    if vinum list -S 2>/dev/null | tr -d "\r" | grep -q "vol.p1.s0.*up"; then break; fi
    sleep 1
    n=$((n+1))
  done
  echo "round $ROUND done after ${n}s" >> /tmp/race_rounds
done
echo ALLDONE >> /tmp/race_rounds
