Skip to content

Commit b9b9882

Browse files
committed
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: coreos#739
1 parent 3e55890 commit b9b9882

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/bios.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) const GRUB_BIN: &str = "usr/sbin/grub2-install";
1616
#[derive(Serialize, Deserialize, Debug)]
1717
struct BlockDevice {
1818
path: String,
19-
pttype: String,
19+
pttype: Option<String>,
2020
parttypename: Option<String>,
2121
}
2222

@@ -118,7 +118,7 @@ impl Bios {
118118
// Find the device with the parttypename "BIOS boot"
119119
for device in devices.blockdevices {
120120
if let Some(parttypename) = &device.parttypename {
121-
if parttypename == "BIOS boot" && device.pttype == "gpt" {
121+
if parttypename == "BIOS boot" && device.pttype == Some("gpt") {
122122
return Ok(Some(device.path));
123123
}
124124
}

0 commit comments

Comments
 (0)