fix(bls): entries path should be constructed from the subpath, not the device path

This commit is contained in:
2025-10-27 00:50:17 -04:00
parent e47c813536
commit 187a84fcf8

View File

@@ -6,10 +6,10 @@ use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
use std::rc::Rc;
use std::str::FromStr;
use uefi::fs::{FileSystem, Path, PathBuf};
use uefi::cstr16;
use uefi::fs::{FileSystem, PathBuf};
use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly};
use uefi::proto::media::fs::SimpleFileSystem;
use uefi::{CString16, cstr16};
/// BLS entry parser.
mod entry;
@@ -48,40 +48,28 @@ pub fn generate(context: Rc<SproutContext>, bls: &BlsConfiguration) -> Result<Ve
// Stamp the path to the BLS directory.
let path = context.stamp(&bls.path);
// Convert the path to a UEFI PathBuf.
let path = PathBuf::from(
CString16::try_from(path.as_str()).context("unable to convert bls path to CString16")?,
// Resolve the path to the BLS directory.
let bls_resolved = utils::resolve_path(context.root().loaded_image_path()?, &path)
.context("unable to resolve bls path")?;
// Construct a filesystem path to the BLS entries directory.
let mut entries_path = PathBuf::from(
bls_resolved
.sub_path
.to_string(DisplayOnly(false), AllowShortcuts(false))
.context("unable to convert bls path to string")?,
);
// Construct the path to the BLS entries directory.
let mut entries_path = path.clone();
entries_path.push(cstr16!("entries"));
// Resolve the path to the BLS entries directory.
let entries_resolved = utils::resolve_path(
context.root().loaded_image_path()?,
&path.to_cstr16().to_string(),
)
.context("unable to resolve bls path")?;
// Open exclusive access to the BLS filesystem.
let fs =
uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(entries_resolved.filesystem_handle)
uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(bls_resolved.filesystem_handle)
.context("unable to open bls filesystem")?;
let mut fs = FileSystem::new(fs);
// Convert the subpath to the BLS entries directory to a string.
let sub_text_path = entries_resolved
.sub_path
.to_string(DisplayOnly(false), AllowShortcuts(false))
.context("unable to convert subpath to string")?;
// Produce a path to the BLS entries directory.
let entries_path = Path::new(&sub_text_path);
// Read the BLS entries directory.
let entries_iter = fs
.read_dir(entries_path)
.read_dir(&entries_path)
.context("unable to read bls entries")?;
// For each entry in the BLS entries directory, parse the entry and add it to the list.