From bb77d0efe779cd9e2e245e7f56f3abbd2baa7d72 Mon Sep 17 00:00:00 2001 From: Tails developers Date: Wed, 15 Feb 2012 12:10:06 +0100 Subject: Check if luks device is already open before trying to open it. --- scripts/live-helpers | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'scripts') diff --git a/scripts/live-helpers b/scripts/live-helpers index a69ce29..8822125 100644 --- a/scripts/live-helpers +++ b/scripts/live-helpers @@ -721,6 +721,21 @@ open_luks_device () opts="${opts} --readonly" fi + if /sbin/cryptsetup status "${name}" >/dev/null 2>&1 + then + re="^[[:space:]]*device:[[:space:]]*\([^[:space:]]*\)$" + opened_dev=$(cryptsetup status ${name} 2>/dev/null | grep "${re}" | sed "s|${re}|\1|") + if [ "${opened_dev}" = "${dev}" ] + then + luks_device="/dev/mapper/${name}" + echo ${luks_device} + return 0 + else + log_warning_msg "Cannot open luks device ${dev} since ${opened_dev} already is opened with its name" + return 1 + fi + fi + load_keymap while true -- cgit v1.2.3