summaryrefslogtreecommitdiffstats
path: root/src/block.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/block.sh')
-rw-r--r--src/block.sh19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/block.sh b/src/block.sh
index f056305..ad94bde 100644
--- a/src/block.sh
+++ b/src/block.sh
@@ -31,7 +31,8 @@ check_block()
local dev="${1}"
if ! [ -b "${dev}" ]; then
- error 2 "$(get_msg 'block_device_invalid')" "${dev}"
+ error "$(get_msg 'block_device_invalid')" "${dev}"
+ return 1
fi
}
@@ -40,17 +41,21 @@ block_mount()
local dev="${1}"
local dir=
- check_block "${dev}"
+ if ! check_block "${dev}"; then
+ return 2
+ fi
rand
dir="$(get_vardata_dir 'mount')/block-$(printf '%010d' ${rand_x})"
if ! mkdir "${dir}"; then
- error 2 "$(get_msg 'block_mkdir_fail')" "${dir}"
+ error "$(get_msg 'block_mkdir_fail')" "${dir}"
+ return 1
fi
if ! mount "${dev}" "${dir}"; then
+ error "$(get_msg 'block_mount_fail')" "${dev}"
rmdir "${dir}"
- error 2 "$(get_msg 'block_mount_fail')" "${dev}"
+ return 1
fi
printf '%s' "${dir}"
@@ -75,11 +80,13 @@ block_umount()
done
if ${timed_out}; then
- error 2 "$(get_msg 'block_umount_fail')" "${dir}"
+ error "$(get_msg 'block_umount_fail')" "${dir}"
+ return 1
fi
if ! rmdir "${dir}"; then
- error 2 "$(get_msg 'block_rmdir_fail')" "${dir}"
+ error "$(get_msg 'block_rmdir_fail')" "${dir}"
+ return 1
fi
return 0