+ echo >&6
+ echo -n "There was an error decrypting ${dev} ... Retry? [Y/n] " >&6
+ read answer
+
+ if [ "$(echo "${answer}" | cut -b1 | tr A-Z a-z)" = "n" ]
+ then
+ return 2
+ fi
+ done
+}
+
+find_persistent_media ()
+{
+ # Scans devices for overlays and snapshots, and returns a whitespace
+ # separated list of how to use them. Only overlays with a partition
+ # label or file name in ${overlays} are returned, and ditto for
+ # snapshots with labels in ${snapshots}.
+ #
+ # When scanning a LUKS device, the user will be asked to enter the
+ # passphrase; on failure to enter it, or if no persistent partitions
+ # or files were found, the LUKS device is closed.
+ #
+ # For a snapshot file the return value is ${label}=${snapdata}", where
+ # ${snapdata} is the parameter used for try_snap().
+ #
+ # For all other cases (overlay/snapshot partition and overlay file) the
+ # return value is "${label}=${device}", where ${device} a device that
+ # can mount the content. In the case of an overlay file, the device
+ # containing the file will remain mounted as a side-effect.
+ #
+ # No devices in ${black_listed_devices} will be scanned, and if
+ # ${white_list_devices} is non-empty, only devices in it will be
+ # scanned.
+
+ overlays="${1}"
+ snapshots="${2}"
+ black_listed_devices="${3}"
+ white_listed_devices="${4}"
+
+ for dev in $(storage_devices "${black_listed_devices}" "${white_listed_devices}")
+ do
+ luks_device=""
+
+ # Checking for a luks device
+ if echo ${PERSISTENT_ENCRYPTION} | grep -qw luks && \
+ /sbin/cryptsetup isLuks ${dev}
+ then
+ if luks_device=$(open_luks_device "${dev}")