# Remove mcoverlay if loaded

if grep mcoverlay /proc/modules &>/dev/null; then
    if [ "`cat /proc/mounts | grep /tmp/mcos/mcos0_sys`" != "" ]; then umount -l /tmp/mcos/mcos0_sys; fi
    if [ "`cat /proc/mounts | grep /tmp/mcos/mcos0_proc`" != "" ]; then umount -l /tmp/mcos/mcos0_proc; fi
    if [ "`cat /proc/mounts | grep /tmp/mcos/linux_proc`" != "" ]; then umount -l /tmp/mcos/linux_proc; fi
    if [ "`cat /proc/mounts | grep /tmp/mcos`" != "" ]; then umount -l /tmp/mcos; fi
    if [ -e /tmp/mcos ]; then rm -rf /tmp/mcos; fi
    if ! rmmod mcoverlay 2>/dev/null; then
	echo "error: removing mcoverlay" >&2
	exit 1
    fi
fi
