Skip to content

Commit

Permalink
bios: Handle empty pttype from lsblk output
Browse files Browse the repository at this point in the history
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
  • Loading branch information
travier committed Oct 2, 2024
1 parent 3e55890 commit b9b9882
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
parttypename: Option<String>,
}

Expand Down Expand Up @@ -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 == Some("gpt") {
return Ok(Some(device.path));
}
}
Expand Down

0 comments on commit b9b9882

Please sign in to comment.