mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-05 04:47:56 +00:00
fixed issue #20: created slam_tomb() that take cares about killing and checking pids
This commit is contained in:
parent
21be9e204e
commit
afd785be62
32
src/tomb
32
src/tomb
@ -757,6 +757,18 @@ exec_safe_post_hooks() {
|
||||
fi
|
||||
}
|
||||
|
||||
slam_tomb() {
|
||||
# $1 = tomb mount point
|
||||
local pidk p
|
||||
pidk=`lsof -t "$1"`
|
||||
if [[ ! -z "$pidk" ]]; then
|
||||
for p in "$pidk"; do
|
||||
func "killing PID $p..."
|
||||
kill -9 $p
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
umount_tomb() {
|
||||
local tombs how_many_tombs
|
||||
local pathmap mapper tombname tombmount loopdev
|
||||
@ -798,26 +810,20 @@ umount_tomb() {
|
||||
pathmap=`dirname "$1"`
|
||||
|
||||
if [ "${pathmap}" = "/dev/mapper" ]; then
|
||||
|
||||
mapper="$1" # argument is the mapper (or none which autofills mapper)
|
||||
tombname="`print $mapper | cut -d. -f2`"
|
||||
tombmount=`mount -l | \
|
||||
awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $3 } '`
|
||||
|
||||
elif [ "$pathmap" = "." ]; then
|
||||
|
||||
tombname="$1" # argument is the name
|
||||
mapper=`mount -l | \
|
||||
awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $1 } '`
|
||||
tombmount=`mount -l | \
|
||||
awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $3 } '`
|
||||
|
||||
else
|
||||
|
||||
tombmount="$1" # argument should be the mount
|
||||
mapper=`mount | awk -vmnt="$tombmount" '/^\/dev\/mapper\/tomb/ { if($3==mnt) print $1 }'`
|
||||
tombname="`print $mapper | cut -d. -f2`"
|
||||
|
||||
fi
|
||||
|
||||
# avoid block when the same tomb is mounted, take only the first
|
||||
@ -837,12 +843,7 @@ umount_tomb() {
|
||||
if [ $SLAM ]; then
|
||||
notice "Slamming tomb $tombname mounted on $tombmount"
|
||||
act "Kill all processes busy inside the tomb"
|
||||
pidk=`lsof -t "$tombmount"`
|
||||
for p in "$pidk"; do
|
||||
pname=`pidof $p`
|
||||
func "killing PID $p of $pname..."
|
||||
kill -9 $p
|
||||
done
|
||||
slam_tomb "$tombmount"
|
||||
else
|
||||
notice "Closing tomb $tombname mounted on $tombmount"
|
||||
fi
|
||||
@ -857,12 +858,7 @@ umount_tomb() {
|
||||
if ! [ $? = 0 ]; then
|
||||
if [ $SLAM ]; then
|
||||
notice "Slamming tomb: killing all processes using this hook"
|
||||
pidk=`lsof -t $b`
|
||||
for p in "$pidk"; do
|
||||
pname=`pidof $p`
|
||||
notice "Killing PID $p of $pname..."
|
||||
kill -9 $p
|
||||
done
|
||||
slam_tomb "$b"
|
||||
umount $b
|
||||
else
|
||||
error "Tomb hook is busy, cannot close tomb."
|
||||
|
Loading…
Reference in New Issue
Block a user