#!/bin/bash
N_ARGS=1
E_ERR=-1
if [ "$#" -ne "$N_ARGS" ] 
then
	echo " Usage: `basename $0` /mnt/device"
	exit $E_ERR
fi
length=`lsof +D "$1" | wc -l `
count=2
if [ "$length" -gt 1 ]
then
while [ "$count" -le "$length" ]
do
	pid=$(lsof +D "$1" |head -$count |tail -1|awk '{print $2}')
	name=$(lsof +D "$1" |head -$count |tail -1|awk '{print $1}')
	echo " Killing .... $name "
	kill -9 $pid
	let "count += 1"
done
	umount $1
else
	echo " No processes are using that device "
fi
exit 0
