From c5e96a777abb841077ee83f414e8c15587fedfb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Wed, 2 Oct 2024 16:12:17 +0200 Subject: [PATCH] bios: Handle empty pttype from lsblk output zram, sr0 (CD/DVD) and LUKS devices generally don't use partitions, thus don't have a partition table and don't have a partition type so this field may be null. Fixes: https://github.com/coreos/bootupd/issues/739 Signed-off-by: Colin Walters --- src/bios.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bios.rs b/src/bios.rs index 11609d28..36e1a78f 100644 --- a/src/bios.rs +++ b/src/bios.rs @@ -16,7 +16,7 @@ pub(crate) const GRUB_BIN: &str = "usr/sbin/grub2-install"; #[derive(Serialize, Deserialize, Debug)] struct BlockDevice { path: String, - pttype: String, + pttype: Option, parttypename: Option, } @@ -118,7 +118,7 @@ impl Bios { // Find the device with the parttypename "BIOS boot" for device in devices.blockdevices { if let Some(parttypename) = &device.parttypename { - if parttypename == "BIOS boot" && device.pttype == "gpt" { + if parttypename == "BIOS boot" && device.pttype.as_deref() == Some("gpt") { return Ok(Some(device.path)); } }