[pkg-cryptsetup-devel] Bug#902449: cryptsetup-initramfs: auto-detection of zfs pool(s)

Jean-Baptiste Lallement jean-baptiste.lallement at canonical.com
Thu Jun 11 09:04:44 BST 2020


Hi,

Here is a patch that ignores zfs filesystems as you recommended by 
returning an empty devno for such devices and then skipping the warning 
and error messages when there is no major/minor number.

-- 
Jean-Baptiste Lallement
irc: jibel
-------------- next part --------------
diff -Nru cryptsetup-2.3.3/debian/changelog cryptsetup-2.3.3/debian/changelog
--- cryptsetup-2.3.3/debian/changelog	2020-06-03 23:41:44.000000000 +0000
+++ cryptsetup-2.3.3/debian/changelog	2020-06-11 06:49:28.000000000 +0000
@@ -1,3 +1,13 @@
+cryptsetup (2:2.3.3-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * d/functions: Return an empty devno for ZFS devices as they don't have
+    major:minor device numbers
+  * d/initramfs/hooks/cryptroot: Ignore and don't print an error message when
+    devices don't have a devno
+
+ -- Jean-Baptiste Lallement <jean-baptiste.lallement at ubuntu.com>  Thu, 11 Jun 2020 06:49:28 +0000
+
 cryptsetup (2:2.3.3-1) unstable; urgency=medium
 
   [ Guilhem Moulin ]
diff -Nru cryptsetup-2.3.3/debian/functions cryptsetup-2.3.3/debian/functions
--- cryptsetup-2.3.3/debian/functions	2020-06-03 23:41:44.000000000 +0000
+++ cryptsetup-2.3.3/debian/functions	2020-06-11 06:49:28.000000000 +0000
@@ -583,6 +583,7 @@
 #   Print the major:minor device ID(s) holding the file system currently
 #   mounted currenty mounted on $mountpoint.
 #   Return 0 on success, 1 on error (if $mountpoint is not a mountpoint).
+#   devno will be empty if the filesystem must be excluded.
 get_mnt_devno() {
     local wantmount="$1" devnos="" uuid dev IFS
     local spec mountpoint fstype _ DEV MAJ MIN
@@ -596,8 +597,15 @@
             # take the last mountpoint if used several times (shadowed)
             unset -v devnos
             spec="$(printf '%b' "$spec")"
-            _resolve_device "$spec" || continue # _resolve_device() already warns on error
             fstype="$(printf '%b' "$fstype")"
+            if [ "$fstype" = "zfs" ]; then
+                # Ignore ZFS entries as they don't have a major/minor and won't
+                # be imported when local-top cryptroot script will ran.
+                # Returns success with empty devno
+                printf ''
+                return 0
+            fi
+            _resolve_device "$spec" || continue # _resolve_device() already warns on error
             if [ "$fstype" = "btrfs" ]; then
                 # btrfs can span over multiple devices
                 if uuid="$(_device_uuid "$DEV")"; then
diff -Nru cryptsetup-2.3.3/debian/initramfs/hooks/cryptroot cryptsetup-2.3.3/debian/initramfs/hooks/cryptroot
--- cryptsetup-2.3.3/debian/initramfs/hooks/cryptroot	2020-06-03 23:41:44.000000000 +0000
+++ cryptsetup-2.3.3/debian/initramfs/hooks/cryptroot	2020-06-11 06:49:28.000000000 +0000
@@ -179,16 +179,18 @@
 
     {
         if devnos="$(get_mnt_devno /)"; then
-            usage=rootfs foreach_cryptdev crypttab_find_and_print_entry $devnos
+            if [ -n "$devnos" ]; then
+                usage=rootfs foreach_cryptdev crypttab_find_and_print_entry $devnos
+            fi
         else
             cryptsetup_message "WARNING: Couldn't determine root device"
         fi
 
-        if devnos="$(get_resume_devno)"; then
+        if devnos="$(get_resume_devno)" && [ -n "$devnos" ]; then
             usage=resume foreach_cryptdev crypttab_find_and_print_entry $devnos
         fi
 
-        if devnos="$(get_mnt_devno /usr)"; then
+        if devnos="$(get_mnt_devno /usr)" && [ -n "$devnos" ]; then
             usage="" foreach_cryptdev crypttab_find_and_print_entry $devnos
         fi
 


More information about the pkg-cryptsetup-devel mailing list