extractor is now called filesystem-device-match

This commit is contained in:
2025-10-13 01:02:51 -07:00
parent 7a63e0325b
commit d63c300bc2
3 changed files with 16 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
version = 1 version = 1
[extractors.boot.filesystem] [extractors.boot.filesystem-device-match]
item = "\\EFI\\BOOT\\kernel.efi" has-item = "\\EFI\\BOOT\\kernel.efi"
[actions.chainload-kernel] [actions.chainload-kernel]
chainload.path = "$boot\\EFI\\BOOT\\kernel.efi" chainload.path = "$boot\\EFI\\BOOT\\kernel.efi"

View File

@@ -1,19 +1,20 @@
use crate::context::SproutContext; use crate::context::SproutContext;
use crate::extractors::filesystem::FileSystemExtractorConfiguration; use crate::extractors::filesystem_device_match::FilesystemDeviceMatchExtractor;
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::rc::Rc; use std::rc::Rc;
pub mod filesystem; pub mod filesystem_device_match;
#[derive(Serialize, Deserialize, Default, Clone)] #[derive(Serialize, Deserialize, Default, Clone)]
pub struct ExtractorDeclaration { pub struct ExtractorDeclaration {
pub filesystem: Option<FileSystemExtractorConfiguration>, #[serde(default, rename = "filesystem-device-match")]
pub filesystem_device_match: Option<FilesystemDeviceMatchExtractor>,
} }
pub fn extract(context: Rc<SproutContext>, extractor: &ExtractorDeclaration) -> Result<String> { pub fn extract(context: Rc<SproutContext>, extractor: &ExtractorDeclaration) -> Result<String> {
if let Some(filesystem) = &extractor.filesystem { if let Some(filesystem) = &extractor.filesystem_device_match {
filesystem::extract(context, filesystem) filesystem_device_match::extract(context, filesystem)
} else { } else {
bail!("unknown extractor configuration"); bail!("unknown extractor configuration");
} }

View File

@@ -11,14 +11,16 @@ use uefi::proto::media::file::{File, FileSystemVolumeLabel};
use uefi::proto::media::fs::SimpleFileSystem; use uefi::proto::media::fs::SimpleFileSystem;
#[derive(Serialize, Deserialize, Default, Clone)] #[derive(Serialize, Deserialize, Default, Clone)]
pub struct FileSystemExtractorConfiguration { pub struct FilesystemDeviceMatchExtractor {
pub label: Option<String>, #[serde(default, rename = "has-label")]
pub item: Option<String>, pub has_label: Option<String>,
#[serde(default, rename = "has-item")]
pub has_item: Option<String>,
} }
pub fn extract( pub fn extract(
context: Rc<SproutContext>, context: Rc<SproutContext>,
device: &FileSystemExtractorConfiguration, extractor: &FilesystemDeviceMatchExtractor,
) -> Result<String> { ) -> Result<String> {
let handles = uefi::boot::find_handles::<SimpleFileSystem>() let handles = uefi::boot::find_handles::<SimpleFileSystem>()
.context("failed to find filesystem handles")?; .context("failed to find filesystem handles")?;
@@ -26,7 +28,7 @@ pub fn extract(
let mut filesystem = uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(handle) let mut filesystem = uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(handle)
.context("failed to open filesystem protocol")?; .context("failed to open filesystem protocol")?;
if let Some(ref label) = device.label { if let Some(ref label) = extractor.has_label {
let want_label = CString16::try_from(context.stamp(label).as_str()) let want_label = CString16::try_from(context.stamp(label).as_str())
.context("failed to convert label to CString16")?; .context("failed to convert label to CString16")?;
let mut root = filesystem let mut root = filesystem
@@ -41,7 +43,7 @@ pub fn extract(
} }
} }
if let Some(ref item) = device.item { if let Some(ref item) = extractor.has_item {
let want_item = CString16::try_from(context.stamp(item).as_str()) let want_item = CString16::try_from(context.stamp(item).as_str())
.context("failed to convert item to CString16")?; .context("failed to convert item to CString16")?;
let mut filesystem = FileSystem::new(filesystem); let mut filesystem = FileSystem::new(filesystem);