]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
Support discard/allow-discard cryptsetup LUKS option. Replace deprecated luksOpen...
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Wed, 26 Nov 2014 20:37:35 +0000 (21:37 +0100)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Wed, 26 Nov 2014 20:37:35 +0000 (21:37 +0100)
mod-luks.sh

index 8cd9959c3342218234578860c51224154791e6df..43bdcaa090c6c2ec2f4176e85dd05a745a4777d8 100644 (file)
@@ -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
 
This page took 0.202212 seconds and 4 git commands to generate.