Skip to content

Commit

Permalink
don't error on unkown type (#69)
Browse files Browse the repository at this point in the history
If the partition type is not known then lets make it default to an
unknown type instead of crashing.
  • Loading branch information
calebccff authored Jun 5, 2021
1 parent 050db58 commit f8dd37a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,7 @@ pub fn file_read_partitions<D: Read + Seek>(

let partname = read_part_name(&mut Cursor::new(&nameraw[..]))?;
let p = Partition {
part_type_guid: Type::from_uuid(&type_guid).map_err(|e| {
Error::new(ErrorKind::Other, format!("Unknown Partition Type: {}", e))
})?,
part_type_guid: Type::from_uuid(&type_guid).unwrap_or_default(),
part_guid,
first_lba: u64::from_le_bytes(read_exact_buff!(flba, reader, 8)),
last_lba: u64::from_le_bytes(read_exact_buff!(llba, reader, 8)),
Expand Down
6 changes: 6 additions & 0 deletions src/partition_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ impl Type {
}
}

impl Default for Type {
fn default() -> Type {
Type { guid: "00000000-0000-0000-0000-000000000000", os: OperatingSystem::None }
}
}

partition_types! {
/// unused
(UNUSED, "00000000-0000-0000-0000-000000000000", OperatingSystem::None),
Expand Down

0 comments on commit f8dd37a

Please sign in to comment.