[Grml-devel] grml-crypt: fix the stop command

Thomas Köhler jean-luc at picard.franken.de
Thu Dec 23 14:14:24 CET 2010


Hello all,
The "stop" command doesn't work with newer device mappers. That
breaks the "stop" command on grml 2010.12-rc0. Here's a fix.

Bye,
Thomas

-- 
 Thomas Köhler       Email:       jean-luc at picard.franken.de
     <><             WWW:              http://gott-gehabt.de
                     IRC:                           tkoehler
                     PGP public key available from Homepage!
-------------- next part --------------
From de0539a53cc856cd3e8a2e4b4916840377d3fdea Mon Sep 17 00:00:00 2001
From: Thomas Koehler <jean-luc at picard.franken.de>
Date: Thu, 23 Dec 2010 13:52:54 +0100
Subject: [PATCH 2/2] Fixed problem with newer device mapper
 Newer device mappers create /dev/mapper/grml-crypt_DEV
 as a symlink to /dev/dm-X, no longer as a block device.
 Unfortunately, after mounting, you only see /dev/dm-X in
 /etc/mtab and /proc/mounts, which broke the "stop" command
 in grml-crypt. By looping over all /dev/mapper/grml-crypt*
 files and checking if this is the correct one, this problem
 can be fixed.

---
 grml-crypt |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/grml-crypt b/grml-crypt
index 47ca333..9b3c53c 100755
--- a/grml-crypt
+++ b/grml-crypt
@@ -211,6 +211,18 @@ function actionStop
   dm_path_=`echo $dm_path_ |awk '{print $1}'` || die "could not get devicemapper name for $tmp_"
   dprint "dm_path_=\"$dm_path_\""
 
+  for dmapper in /dev/mapper/grml-crypt* ; do
+    link=`readlink $dmapper | sed -e 's#^\.\./#/dev/#'`
+    dprint "looping device mapper devices, dmapper=$dmapper => link=$link"
+    if [ "$link" = "$dm_path_" ] ; then
+      tmp_dm_path_="$dmapper"
+    fi
+  done
+
+  if [ ! -z "$tmp_dm_path_" ] ; then
+    dm_path_="$tmp_dm_path_"
+  fi
+
   dm_name_="${dm_path_##*/}"
   dprint "dm_name_=\"$dm_name_\""
 
-- 
1.7.2.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://ml.grml.org/pipermail/grml-devel/attachments/20101223/301de693/attachment.pgp>


More information about the Grml-devel mailing list