fix(filesystem-device-match): bail early if no criteria is provided

This commit is contained in:
2025-10-28 17:10:28 -04:00
parent 000e3ea6c7
commit fe714cc411

View File

@@ -88,6 +88,15 @@ pub fn extract(
context: Rc<SproutContext>, context: Rc<SproutContext>,
extractor: &FilesystemDeviceMatchExtractor, extractor: &FilesystemDeviceMatchExtractor,
) -> Result<String> { ) -> Result<String> {
// If no criteria are provided, bail with an error.
if extractor.has_label.is_none()
&& extractor.has_item.is_none()
&& extractor.has_partition_uuid.is_none()
&& extractor.has_partition_type_uuid.is_none()
{
bail!("at least one criteria is required for filesystem-device-match");
}
// Find all the filesystems inside the UEFI stack. // Find all the filesystems inside the UEFI stack.
let handles = uefi::boot::find_handles::<SimpleFileSystem>() let handles = uefi::boot::find_handles::<SimpleFileSystem>()
.context("unable to find filesystem handles")?; .context("unable to find filesystem handles")?;