improve tomb umount checks avoiding grep call

consolidate use of `list_tomb_mounts` also inside umount_tomb
this should fix #315
This commit is contained in:
Jaromil 2019-05-22 01:03:00 +02:00
parent 7b06be5d43
commit 2b8eec6ba5

18
tomb
View File

@ -2942,22 +2942,18 @@ umount_tomb() {
# posing a security risk. # posing a security risk.
# See https://github.com/dyne/Tomb/issues/273 # See https://github.com/dyne/Tomb/issues/273
# checking for tombs # checking for tombs still mounted
mount | grep -w "$tombmount" >/dev/null mounted_tombs=(`list_tomb_mounts`)
mount_status=$? for t in ${mounted_tombs}; do
# return value of 0 for grep means it found at least one entry usedmount=${t[(ws:;:)2]}
# return value of 1 means nothing was found, implying, the tomb [[ "$usedmount" == "$tombmount" ]] && {
# mount was already umounted.
if [ $mount_status = 0 ]; then
# Tomb was not umounted through the above command # Tomb was not umounted through the above command
# Will do so now # Will do so now
_verbose "Performing umount of ::1 mount point::" $tombmount _verbose "Performing umount of ::1 mount point::" $tombmount
_sudo umount ${tombmount} _sudo umount ${tombmount}
[[ $? = 0 ]] || { _failure "Tomb is busy, cannot umount!" } [[ $? = 0 ]] || { _failure "Tomb is busy, cannot umount!" }
else }
# Tomb was already umounted, will not do it again done
_warning "Tomb was already umounted, possibly through a binded directory"
fi
# If we used a default mountpoint and is now empty, delete it # If we used a default mountpoint and is now empty, delete it
tombname_regex=${tombname//\[/} tombname_regex=${tombname//\[/}