summaryrefslogtreecommitdiff
path: root/cryptfs.bin.in
diff options
context:
space:
mode:
Diffstat (limited to 'cryptfs.bin.in')
-rw-r--r--cryptfs.bin.in33
1 files changed, 29 insertions, 4 deletions
diff --git a/cryptfs.bin.in b/cryptfs.bin.in
index 9e8e1e7..8bfa29a 100644
--- a/cryptfs.bin.in
+++ b/cryptfs.bin.in
@@ -147,6 +147,8 @@ is_unlocked() {
do_mount() {
local inner_fs
+ local max_tries
+ local mount_paramters
if is_mounted "$1"; then
return
fi
@@ -176,7 +178,15 @@ do_mount() {
if [ -n "${inner_fs}" ]; then
do_unmount -l "${inner_fs}"
fi
- mount $(mount_details all "$1")
+ max_tries=10
+ mount_parameters=$(mount_details all "$1")
+ while ! mount ${mount_parameters}; do
+ max_tries=$((max_tries-1))
+ if [ ${max_tries} -le 0 ]; then
+ exit 1
+ fi
+ sleep 1
+ done
if [ -n "${inner_fs}" ]; then
do_mount "${inner_fs}"
fi
@@ -185,6 +195,7 @@ do_mount() {
do_unmount() {
local inner_fs
local lazy
+ local mount_point
if [ "x$1" = 'x-l' ]; then
lazy='-l'
shift
@@ -198,7 +209,11 @@ do_unmount() {
if [ -n "${inner_fs}" ]; then
do_unmount -l "${inner_fs}"
fi
- umount ${lazy} $(mount_details mp "$1")
+ mount_point=$(mount_details mp "$1")
+ while ! umount ${lazy} "${mount_point}"; do
+ fuser -k -M -m "${mount_point}"
+ sleep 1
+ done
if [ -n "${inner_fs}" ]; then
do_mount "${inner_fs}"
fi
@@ -206,13 +221,23 @@ do_unmount() {
do_crypt_close() {
if is_unlocked "$1"; then
- cryptsetup luksClose "$1"
+ while ! cryptsetup luksClose "$1"; do
+ sleep 1
+ done
fi
}
do_crypt_open() {
+ local max_tries
if ! is_unlocked "$1"; then
- cryptsetup luksOpen "$2" "$1" --key-file="$3"
+ max_tries=10
+ while ! cryptsetup luksOpen "$2" "$1" --key-file="$3"; do
+ sleep 1
+ max_tries=$((max_tries-1))
+ if [ ${max_tries} -le 0 ]; then
+ exit 1
+ fi
+ done
fi
}