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: #739
Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
travier authored and cgwalters committed Oct 2, 2024
1 parent 3e55890 commit c5e96a7
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.as_deref() == Some("gpt") {
return Ok(Some(device.path));
}
}
Expand Down

0 comments on commit c5e96a7

Please sign in to comment.