#!/usr/local/plan9/bin/rc
# usage: un9fs
# un9p cleans up 9fs related processes
#
rfork e
path=(/usr/local/plan9/bin $path)
if(! ~ $#* 0){
  echo 'usage: un9fs'
  exit usage
}
pid=`{/bin/ps ax|awk '$5 ~ /factotum|9pserve|srv|9pfs/{print $1}'}
if(~ $#pid 0)
  echo 'no 9p related processes'
if not
  /bin/kill -KILL $pid
for(f in `{ls /n})
  unmount $f
unmount /mnt/factotum
rm /srv/*