#!/bin/sh

kldstat -q -m nmdm
if [ $? -ne 0 ]; then
	echo "Loading nmdm.ko"
	sudo kldload nmdm
fi

iter=0
while [ 1 ]; do
	iter=$((iter + 1))
	echo "Iteration $iter"
	sudo /tmp/a.out /dev/nmdm0A &
	pid=$!
	sleep 3
	echo "Revoking nmdm0A"
	sudo revoke /dev/nmdm0A
	wait $pid
done
