Skip to content

Commit c3e883c

Browse files
committed
fix(utils): when retrieving the partition guid, if the guid is zero, return none
1 parent f69d4b9 commit c3e883c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/utils.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,15 @@ pub fn unique_hash(input: &str) -> String {
201201
/// Represents the type of partition GUID that can be retrieved.
202202
#[derive(PartialEq, Eq)]
203203
pub enum PartitionGuidForm {
204+
/// The partition GUID is the unique partition GUID.
204205
Partition,
206+
/// The partition GUID is the partition type GUID.
205207
PartitionType,
206208
}
207209

208210
/// Retrieve the partition / partition type GUID of the device root `path`.
209211
/// This only works on GPT partitions. If the root is not a GPT partition, None is returned.
212+
/// If the GUID is all zeros, this will return None.
210213
pub fn partition_guid(path: &DevicePath, form: PartitionGuidForm) -> Result<Option<Guid>> {
211214
// Clone the path so we can pass it to the UEFI stack.
212215
let path = path.to_boxed();
@@ -238,7 +241,8 @@ pub fn partition_guid(path: &DevicePath, form: PartitionGuidForm) -> Result<Opti
238241
// Match the form of the partition GUID.
239242
PartitionGuidForm::Partition => entry.unique_partition_guid,
240243
PartitionGuidForm::PartitionType => entry.partition_type_guid.0,
241-
}))
244+
})
245+
.filter(|guid| !guid.is_zero()))
242246
} else {
243247
Ok(None)
244248
}

0 commit comments

Comments
 (0)