[projects/geninitrd] Support discard/allow-discard cryptsetup LUKS option. Replace deprecated luksOpen with current metho

arekm arekm at pld-linux.org
Wed Nov 26 21:37:39 CET 2014


commit 7fcd846e193ef5665ff5d1848ec5df00fac9f31d
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Wed Nov 26 21:37:35 2014 +0100

    Support discard/allow-discard cryptsetup LUKS option. Replace deprecated luksOpen with current method.

 mod-luks.sh | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/mod-luks.sh b/mod-luks.sh
index 8cd9959..43bdcaa 100644
--- a/mod-luks.sh
+++ b/mod-luks.sh
@@ -134,15 +134,27 @@ luks_crypttab() {
 			if key_is_random "$key"; then
 				die "$dst: LUKS requires non-random key, skipping"
 			fi
-			if [ -n "$opt" ]; then
-				warn "$dst: options are invalid for LUKS partitions, ignoring them"
-			fi
 			if [ "$key" ]; then
 				keyfile=/etc/.$dst.key
 				inst $key $keyfile
 			fi
 
-			verbose "+ cryptsetup ${keyfile:+-d $keyfile} luksOpen '$src' '$dst'"
+			crypttab_opt=""
+			old_IFS="$IFS"
+			IFS=","
+			for option in $opt; do
+				case "$option" in
+					discard|allow-discards)
+						crypttab_opt="$crypttab_opt --allow-discards"
+						;;
+					*)
+						warn "$dst: option \'$opt\' is invalid for LUKS partitions, ignored"
+						;;
+				esac
+			done
+			IFS="$old_IFS"
+
+			verbose "+ cryptsetup ${keyfile:+-d $keyfile} open --type luks $crypttab_opt '$src' '$dst'"
 			add_linuxrc <<-EOF
 			debugshell
 
@@ -169,7 +181,7 @@ luks_crypttab() {
 				crypt_status=\$(cryptsetup \$cryptsetup_opt status '$dst')
 				if [ "\${crypt_status%%is inactive.}" != "\$crypt_status" ]; then
 					# is inactive
-					cryptsetup \$cryptsetup_opt ${keyfile:+-d $keyfile} luksOpen "\$luksdev" '$dst' <&1
+					cryptsetup \$cryptsetup_opt ${keyfile:+-d $keyfile} open --type luks $crypttab_opt "\$luksdev" '$dst' <&1
 				fi
 			fi
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/geninitrd.git/commitdiff/7fcd846e193ef5665ff5d1848ec5df00fac9f31d



More information about the pld-cvs-commit mailing list