Comments (4)
Hi, thanks for filing this. Here are my initial thoughts:
- For composing errors, it might be best to make your own error enum? E.g.
Or potentially use
#[derive(Debug)] enum GetDropinDirectoryError { LoadedImageError(uefi::Error), NoFilePath, Oom, DevicePathToTextError(uefi::proto::device_path::DevicePathToTextError), InvalidPath(uefi::data_types::FromStrError), FileSystemError(uefi::fs::FileSystemResult), }
thiserror
.
Or you could maybe useBox<dyn Error>
or theanyhow
crate, if you are OK with unstable features to enable theError
trait in core. - Adding a
join
method for paths sounds good, I think this was discussed during the initial implementation and left as future work. - I think adding
is_ascii
toChar16
andCStr16
(which implicitly provides it forCString16
as well) should be uncontroversial if you want to open a PR with just that part we can get it reviewed quickly.- In your WIP PR there's also a new
SliceLikeChar16
trait, I'm not sure if that's necessary -- would want to see stronger motivation for it - I don't think
is_utf8
would make sense, sinceCStr16
is inherently UCS-2 and can always be losslessly converted to utf8.
- In your WIP PR there's also a new
- Re
std::path::Path
, there is work underway to support std for the UEFI targets: rust-lang/rust#100499. If you use a nightly compiler that could already be an option for you. uefi::fs::FileSystem
is intended to mostly mirrorstd::fs
; both of them operate on paths rather than file handles. So for your get-dropin-dir example, I think you could either have it just returntarget_directory
as a path, or you could switch to using the lower-levelSimpleFileSystem
API. The latter requires keeping the protocol open for the duration of your use, otherwise theDirectory
handle would become invalid.
from uefi-rs.
To give an interesting example, how would you complete this:
/// Returns the "default" drop-in directory if it exists.
/// This will be in general $loaded_image_path.extra/
pub fn get_default_dropin_directory(boot_services: &BootServices) -> Option<Directory> {
if let Some(image_file_path) = boot_services
.open_protocol_exclusive::<LoadedImage>(boot_services.image_handle())
.map(|loaded_image| loaded_image.file_path())? {
// We could use LoadedImageDevicePath to get the full device path
// and perform replacement of the last node before END_ENTIRE
// by another node containing the filename + .extra
// But this is as much tedious as performing a conversion to string
// then opening the root directory and finding the new directory.
let image_file_string = image_file_path.to_string(boot_services, DisplayOnly(false), AllowShortcuts(false))?
.expect("Failed to obtain the string representation of the loaded image file path; not enough memory?");
let target_directory: CString16 = format!("{}.extra", image_file_string);
let fs = uefi::fs::FileSystem::new(boot_services.get_image_file_system(
boot_services.image_handle()
)?);
if let Ok(info) = fs.metadata(target_directory.into()) {
if info.is_directory() {
}
}
}
None
}
Given that fs.open
is private, there's no way for me to open this info without re-opening the SFS, opening the root directory, opening the path and into-ing into that Directory.
I think having a way to go from high level to low level would be very appreciable because I don't want to move around listing of directories, only a file handle.
from uefi-rs.
Yes, as @nicholasbishop told, our goal for uefi::fs::FileSystem
is to match std::fs
as closely as possible. The same is true for uefi::fs::Path
.
- I'm here with Nicholas. We should not convert a high-level
FileSystem
error to an low-leveluefi
-error. This feels wrong. Working with theError
trait might be a reasonable solution, or just use a new enum covering all error variants. - (no additional remarks)
- (no additional remarks)
- (no additional remarks)
- (no additional remarks)
from uefi-rs.
Opened #1008 for the is_ascii
stuff, closed the SliceLike stuff, I am fine with inlining the iteration if you prefer, it means that is_ascii
is impossible on &[Char16]
though, but it's fine I guess.
from uefi-rs.
Related Issues (20)
- Allow getting a MemoryMap from a pointer
- how can I found the `Miscellaneous Protocols` and use it HOT 17
- How do I get a device path of a efi image? HOT 2
- Nuke "uefi-services" from repository
- Feature Request: Implementing MP Protocol Compatibility in Hyper-V HOT 3
- Whether a lifecycle container/manager can be provided to store the currently open protocol? HOT 4
- Example application fails to build with "could not find `helpers` in `uefi`" HOT 3
- `uefi::helpers` not found / Rust UEFI Book out of sync HOT 2
- Can not write file HOT 2
- No graphics HOT 2
- Set default features for uefi crate
- Use `cargo xtask fmt --check` in CI
- After 1.83 is released: bump MSRV and un-gate error_in_core impls
- make MemoryMap own its buffer (Vec) HOT 2
- CI failing due to dead_code warnings on nightly HOT 2
- Change the book to build from the latest tag instead of the latest commit on main HOT 1
- Need help for ACPI table, rsdt and xsdt entries are aberrant HOT 3
- Just a question about how I can exit boot services correctly. HOT 4
- Redesign Allocator API HOT 5
- MemoryMapRef/MemoryMapRefMut constructors HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uefi-rs.