Blame 0015-91crypt-loop-use-initqueue-for-cleanup-strategy.patch

Harald Hoyer 12f6cc
From df68781fca048de2f880be37ab9e1ede9bea5051 Mon Sep 17 00:00:00 2001
Harald Hoyer 12f6cc
From: Leho Kraav <leho@kraav.com>
Harald Hoyer 12f6cc
Date: Tue, 24 Jul 2012 15:08:54 +0300
Harald Hoyer 12f6cc
Subject: [PATCH] 91crypt-loop: use initqueue for cleanup strategy
Harald Hoyer 12f6cc
Harald Hoyer 12f6cc
---
Harald Hoyer 12f6cc
 modules.d/90crypt/crypt-lib.sh           | 3 +++
Harald Hoyer 12f6cc
 modules.d/91crypt-loop/crypt-loop-lib.sh | 5 +++++
Harald Hoyer 12f6cc
 2 files changed, 8 insertions(+)
Harald Hoyer 12f6cc
Harald Hoyer 12f6cc
diff --git a/modules.d/90crypt/crypt-lib.sh b/modules.d/90crypt/crypt-lib.sh
Harald Hoyer 12f6cc
index 5f7567e..d5caa85 100755
Harald Hoyer 12f6cc
--- a/modules.d/90crypt/crypt-lib.sh
Harald Hoyer 12f6cc
+++ b/modules.d/90crypt/crypt-lib.sh
Harald Hoyer 12f6cc
@@ -188,6 +188,9 @@ readkey() {
Harald Hoyer 12f6cc
             if [ -f /lib/dracut-crypt-loop-lib.sh ]; then
Harald Hoyer 12f6cc
                 . /lib/dracut-crypt-loop-lib.sh
Harald Hoyer 12f6cc
                 loop_decrypt "$mntp" "$keypath" "$keydev" "$device"
Harald Hoyer 12f6cc
+                initqueue --onetime --finished --unique --name "crypt-loop-cleanup-99-$(basename $mntp)" \
Harald Hoyer 12f6cc
+                    $(command -v umount) "$mntp; " $(command -v rmdir) "$mntp"
Harald Hoyer 12f6cc
+                return 0
Harald Hoyer 12f6cc
             else
Harald Hoyer 12f6cc
                 die "No loop file support to decrypt '$keypath' on '$keydev'."
Harald Hoyer 12f6cc
             fi
Harald Hoyer 12f6cc
diff --git a/modules.d/91crypt-loop/crypt-loop-lib.sh b/modules.d/91crypt-loop/crypt-loop-lib.sh
Harald Hoyer 12f6cc
index 63a553c..6774e7d 100644
Harald Hoyer 12f6cc
--- a/modules.d/91crypt-loop/crypt-loop-lib.sh
Harald Hoyer 12f6cc
+++ b/modules.d/91crypt-loop/crypt-loop-lib.sh
Harald Hoyer 12f6cc
@@ -32,6 +32,11 @@ loop_decrypt() {
Harald Hoyer 12f6cc
             --tty-echo-off
Harald Hoyer 12f6cc
 
Harald Hoyer 12f6cc
         [ -b $key ] || die "Tried setting it up, but keyfile block device was still not found!" 
Harald Hoyer 12f6cc
+
Harald Hoyer 12f6cc
+        initqueue --onetime --finished --unique --name "crypt-loop-cleanup-10-$(basename $key)" \
Harald Hoyer 12f6cc
+            $(command -v cryptsetup) "luksClose $key"
Harald Hoyer 12f6cc
+        initqueue --onetime --finished --unique --name "crypt-loop-cleanup-20-$(basename $loopdev)" \
Harald Hoyer 12f6cc
+            $(command -v losetup) "-d $loopdev"
Harald Hoyer 12f6cc
     else
Harald Hoyer 12f6cc
         info "Existing keyfile found, re-using it for $device"
Harald Hoyer 12f6cc
     fi