[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#361147: partman-base: add dm-crypt detection support



Package: partman-base
Version: 80
Severity: wishlist
Tags: patch

Hi,

the attached patch is necessary in order to show decent descriptions for encrypted volumes when using partman-crypt. Without the patch, everything under /dev/mapper is listed as a lvm lv.

Regards,
David Härdeman

Index: partman-base/debian/partman-base.templates
===================================================================
--- partman-base.orig/debian/partman-base.templates	2006-03-23 23:40:53.000000000 +0100
+++ partman-base/debian/partman-base.templates	2006-04-06 22:27:20.000000000 +0200
@@ -252,6 +252,10 @@
 Type: text
 _Description: RAID%s device #%s
 
+Template: partman/text/dmcrypt_volume
+Type: text
+_Description: Encrypted volume (%s)
+
 Template: partman/text/lvm_lv
 Type: text
 _Description: LVM VG %s, LV %s
Index: partman-base/definitions.sh
===================================================================
--- partman-base.orig/definitions.sh	2006-04-04 22:37:04.000000000 +0200
+++ partman-base/definitions.sh	2006-04-06 23:54:46.000000000 +0200
@@ -633,17 +633,29 @@
 	    printf "$RET" ${type} ${device}
 	    ;;
 	/dev/mapper/*)
-	    # LVM2 devices are found as /dev/mapper/<vg>-<lv>.  If the vg
-	    # or lv contains a dash, the dash is replaced by two dashes.
-	    # In order to decode this into vg and lv, first find the
-	    # occurance of one single dash to split the string into vg and
-	    # lv, and then replace two dashes next to each other with one.
-	    vglv=${1#/dev/mapper/}
-	    vglv=`echo "$vglv" | sed -e 's/\([^-]\)-\([^-]\)/\1 \2/' | sed -e 's/--/-/g'`
-	    vg=`echo "$vglv" | cut -d" " -f1`
-	    lv=`echo "$vglv" | cut -d" " -f2`
-	    db_metaget partman/text/lvm_lv description
-	    printf "$RET" $vg $lv
+        # First of all, check if this is a dm-crypt device
+        type=""
+        if [ -x /sbin/dmsetup ]; then
+            type=$(/sbin/dmsetup table $swap | head -1 | cut -d " " -f3)
+        fi
+
+        if [ $type = crypt ]; then
+            mapping=${1#/dev/mapper/}
+            db_metaget partman/text/dmcrypt_volume description
+            printf "$RET" $mapping
+        else
+            # LVM2 devices are found as /dev/mapper/<vg>-<lv>.  If the vg
+            # or lv contains a dash, the dash is replaced by two dashes.
+            # In order to decode this into vg and lv, first find the
+            # occurance of one single dash to split the string into vg and
+            # lv, and then replace two dashes next to each other with one.
+            vglv=${1#/dev/mapper/}
+            vglv=`echo "$vglv" | sed -e 's/\([^-]\)-\([^-]\)/\1 \2/' | sed -e 's/--/-/g'`
+            vg=`echo "$vglv" | cut -d" " -f1`
+            lv=`echo "$vglv" | cut -d" " -f2`
+            db_metaget partman/text/lvm_lv description
+            printf "$RET" $vg $lv
+        fi
 	    ;;
 	/dev/loop/*)
 	    n=${1#/dev/loop/}

Reply to: