mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 19:52:22 +00:00
fix(autoconfigure): skip filesystems that can't be opened
If the device path or filesystem protocol of any detected filesystem could not be opened, autoconfiguration failed entirely and boot was aborted. Log a warning and skip that filesystem instead, so the other filesystems are still autoconfigured.
This commit is contained in:
1 parent
84bd84b7d2
commit
2da1cea25c
1 file changed
+16
-6
@@ -1,5 +1,6 @@
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use edera_sprout_config::RootConfiguration;
|
use edera_sprout_config::RootConfiguration;
|
||||||
|
use log::warn;
|
||||||
use uefi::fs::FileSystem;
|
use uefi::fs::FileSystem;
|
||||||
use uefi::proto::device_path::DevicePath;
|
use uefi::proto::device_path::DevicePath;
|
||||||
use uefi::proto::media::fs::SimpleFileSystem;
|
use uefi::proto::media::fs::SimpleFileSystem;
|
||||||
@@ -25,15 +26,24 @@ pub fn autoconfigure(config: &mut RootConfiguration) -> Result<()> {
|
|||||||
// For each filesystem that was detected, scan it for supported autoconfig mechanisms.
|
// For each filesystem that was detected, scan it for supported autoconfig mechanisms.
|
||||||
for handle in filesystem_handles {
|
for handle in filesystem_handles {
|
||||||
// Acquire the device path root for the filesystem.
|
// Acquire the device path root for the filesystem.
|
||||||
let root = {
|
// A filesystem that can't be opened is skipped, as it should not prevent
|
||||||
uefi::boot::open_protocol_exclusive::<DevicePath>(handle)
|
// autoconfiguring the other filesystems.
|
||||||
.context("unable to get root for filesystem")?
|
let root = match uefi::boot::open_protocol_exclusive::<DevicePath>(handle) {
|
||||||
.to_boxed()
|
Ok(root) => root.to_boxed(),
|
||||||
|
Err(error) => {
|
||||||
|
warn!("skipping filesystem, unable to get its root: {}", error);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Open the filesystem that was detected.
|
// Open the filesystem that was detected.
|
||||||
let filesystem = uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(handle)
|
let filesystem = match uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(handle) {
|
||||||
.context("unable to open filesystem")?;
|
Ok(filesystem) => filesystem,
|
||||||
|
Err(error) => {
|
||||||
|
warn!("skipping filesystem, unable to open it: {}", error);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Trade the filesystem protocol for the uefi filesystem helper.
|
// Trade the filesystem protocol for the uefi filesystem helper.
|
||||||
let mut filesystem = FileSystem::new(filesystem);
|
let mut filesystem = FileSystem::new(filesystem);
|
||||||
|
|||||||
Reference in new issue
Block a user