summaryrefslogtreecommitdiffstats
path: root/lib/block.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/block.sh')
-rw-r--r--lib/block.sh23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/block.sh b/lib/block.sh
index 7060690..d83572e 100644
--- a/lib/block.sh
+++ b/lib/block.sh
@@ -22,6 +22,7 @@
_BLOCK_SM=1
use rand
+use vardata
is_block()
{
@@ -31,25 +32,31 @@ is_block()
return ${?}
}
-block_mount()
+check_block()
{
local dev="${1}"
- local dir=
if ! [ -b "${dev}" ]; then
error 2 "$(get_msg 'block_device_invalid')"
fi
+}
+
+block_mount()
+{
+ local dev="${1}"
+ local dir=
+
+ check_block "${dev}"
rand
- # FIXME: Hardcoded tmpdir
- dir="/tmp/prokit-block-$(printf '%010d' ${rand_x})"
+ dir="$(get_vardata_dir 'mount')/block-$(printf '%010d' ${rand_x})"
if ! mkdir "${dir}"; then
- error 2 "$(get_msg 'block_mkdir_fail' "${dir}")"
+ error 2 "$(get_msg 'block_mkdir_fail')" "${dir}"
fi
if ! mount "${dev}" "${dir}"; then
rmdir "${dir}"
- error 2 "$(get_msg 'block_mount_fail' "${dev}")"
+ error 2 "$(get_msg 'block_mount_fail')" "${dev}"
fi
printf '%s' "${dir}"
@@ -74,11 +81,11 @@ block_umount()
done
if ${timed_out}; then
- error 2 "$(get_msg 'block_umount_fail' "${dir}")"
+ error 2 "$(get_msg 'block_umount_fail')" "${dir}"
fi
if ! rmdir "${dir}"; then
- error 2 "$(get_msg 'block_rmdir_fail' "${dir}")"
+ error 2 "$(get_msg 'block_rmdir_fail')" "${dir}"
fi
return 0