Added patch to support resuming from encrypted swap. The patch was submitted to...
authorChris Gianelloni <wolf31o2@gentoo.org>
Mon, 13 Nov 2006 19:20:38 +0000 (19:20 +0000)
committerChris Gianelloni <wolf31o2@gentoo.org>
Mon, 13 Nov 2006 19:20:38 +0000 (19:20 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@457 67a159dc-881f-0410-a524-ba9dfbe2cb84

ChangeLog
generic/initrd.scripts
generic/linuxrc

index d96e4ea13620d127c5810d4842f9d283400fe5f9..b5e2bbeca016d6b66e56d4ffea39d582e1e27d09 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 # Copyright 2006-2006 Gentoo Foundation; Distributed under the GPL v2
 # $Header: $
 
+  13 Nov 2006; Chris Gianelloni <wolf31o2@gentoo.org>
+  generic/initrd.scripts, generic/linuxrc:
+  Added patch to support resuming from encrypted swap. The patch was submitted
+  to bug #152441.
+
   25 Oct 2006; Chris Gianelloni <wolf31o2@gentoo.org> genkernel:
   This is the 3.4.4 release.
 
index 08ed27ff69bfcd29632383723f0d0da9e8660a8c..299870e08b06901ca599dffc6197b45a6f607c8b 100644 (file)
@@ -549,35 +549,73 @@ startVolumes() {
        fi
 }
 
-startLUKS() {
-       if [ -n "${LUKS_ROOT}" ]
+# Open a LUKS device
+# $1 LUKS device
+# $2 LUKS name
+openLUKS() {
+       LUKS_DEVICE="$1"
+       LUKS_NAME="$2"
+       if [ -e /sbin/cryptsetup ]
        then
-               if [ -e /sbin/cryptsetup ]
-               then
-                       if cryptsetup isLuks ${LUKS_ROOT}
+               while [ 1 ]
+               do
+                       if [ "${LUKS_DEVICE}" = '' ]
                        then
-                               good_msg "Opening LUKS device ${LUKS_ROOT}"
-
-                               cryptsetup luksOpen ${LUKS_ROOT} root
-                               if [ ! "$?" -eq '0' ]
-                               then
-                                       bad_msg "Failed open LUKS device ${LUKS_ROOT}"
-                               fi
-
-                               if [ -n "${REAL_ROOT}" ]
+                               # LUKS device could not be opened. Prompt user for device.
+                               bad_msg "The LUKS ${LUKS_NAME} block device is not detected."
+                               echo "   Please specify a ${LUKS_NAME} LUKS device to open, "q" to skip, or "shell" for a shell..."
+                               echo -n "LUKS ${LUKS_NAME}() :: "
+                               read LUKS_DEVICE
+                               continue
+                       elif [ "${LUKS_DEVICE}" = 'shell' ]
+                       then
+                               run_shell
+                               
+                               LUKS_DEVICE=''
+                               continue
+                       elif [ "${LUKS_DEVICE}" = 'q' ]
+                       then
+                               break
+                       else
+                               if cryptsetup isLuks ${LUKS_DEVICE}
                                then
-                                       # Rescan volumes
-                                       startVolumes
+                                       good_msg "Opening LUKS device ${LUKS_DEVICE}"
+                                       
+                                       cryptsetup luksOpen ${LUKS_DEVICE} ${LUKS_NAME}
+                                       if [ ! "$?" -eq '0' ]
+                                       then
+                                               bad_msg "Failed open LUKS device ${LUKS_DEVICE}"
+                                       else
+                                               break
+                                       fi
                                else
-                                       REAL_ROOT="/dev/mapper/root"
+                                       bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header"
                                fi
-                       else
-                               bad_msg "The LUKS device ${LUKS_ROOT} does not contain a LUKS hearder"
                        fi
+                       LUKS_DEVICE=''
+               done
+       else
+               bad_msg "The initrd does not support LUKS"
+       fi
+}
+
+startLUKS() {
+       if [ -n "${LUKS_ROOT}" ]
+       then
+               openLUKS "${LUKS_ROOT}" "root" 
+               if [ -n "${REAL_ROOT}" ]
+               then
+                       # Rescan volumes
+                       startVolumes
                else
-                       bad_msg "The initrd does not support LUKS"
+                       REAL_ROOT="/dev/mapper/root"
                fi
        fi
+       if [ -n "${LUKS_SWAP}" ]
+       then
+               openLUKS "${LUKS_SWAP}" "swap" 
+               break
+       fi
 }
 
 sdelay() {
index 441c09f474849000660791e1c6a34c9c7837b98f..ecf96c749ea518be02c06b19307b11ae4bf9cb8c 100644 (file)
@@ -175,6 +175,9 @@ do
                crypt_root\=*)
                        LUKS_ROOT=`parse_opt "${x}"`
                ;;
+               crypt_swap\=*)
+                       LUKS_SWAP=`parse_opt "${x}"`
+               ;;
        esac
 done
 
@@ -226,7 +229,7 @@ setup_md_device
 # Scan volumes
 startVolumes
 
-# Iinitialize LUKS root device
+# Initialize LUKS root device
 startLUKS
 
 # Set up unionfs