From 715708dc3d2771d41b35c7a7aa478308ab862d76 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 30 Mar 2025 22:25:22 +0200 Subject: [PATCH] cs/mkdir --- sh/cryptsetup.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sh/cryptsetup.sh b/sh/cryptsetup.sh index ba94a8a..a4792e6 100644 --- a/sh/cryptsetup.sh +++ b/sh/cryptsetup.sh @@ -52,32 +52,37 @@ rwx_crypt() { local device case "${action}" in "${action_open}") + # find device if ! device="$(rwx_crypt_device)"; then rwx_log_error 4 "No device available" fi + # make directory + if ! mkdir --parents "${RWX_CRYPT_VAR}"; then + rwx_log_error 5 "Making failure: ${RWX_CRYPT_VAR}" + fi # record device if ! rwx_file_write \ "${RWX_CRYPT_VAR}/${crypt_arg}" "${device}"; then - rwx_log_error 5 "Writing failure: ${device}" + rwx_log_error 6 "Writing failure: ${device}" fi # connect device if ! qemu-nbd --connect "${device}" "${crypt_file}"; then - rwx_log_error 6 "Connection failure: ${device}" + rwx_log_error 7 "Connection failure: ${device}" fi # open device if ! echo "${pass_phrase}" | cryptsetup luksOpen "${device}" "${crypt_arg}"; then - rwx_log_error 7 "Opening failure: ${device}" + rwx_log_error 8 "Opening failure: ${device}" fi # make mount directory if ! mkdir --parents "${crypt_mount}"; then - rwx_log_error 8 "Making failure: ${crypt_mount}" + rwx_log_error 9 "Making failure: ${crypt_mount}" fi # mount file system if ! mount \ --options "autodefrag,compress-force=zstd" \ "${crypt_map}" "${crypt_mount}"; then - rwx_log_error 9 "Mounting failure: ${crypt_map}" + rwx_log_error 10 "Mounting failure: ${crypt_map}" fi ;; "${action_close}")