#!/bin/sh

MNTLOCK=/tmp/mntlock

flock -e $MNTLOCK
MNT=`sed -n "s|^$DEVNAME	\(.*\)|\1|p" /etc/mnts`
if [ -n "$MNT" ]; then
  sed -i -n "\|^$DEVNAME.*|T;p" /etc/mnts
  flock -u
  (
  umount -l "$MNT"
  while [ "$?" = 16 ]; do # umount returned EBUSY
    sleep 1
    umount -l "$MNT"
  done
  rmdir "$MNT"
  )&
else
  flock -u
fi
