Skip to content

Commit 24c8117

Browse files
authored
Merge pull request #1399 from nicholasbishop/bishop-simplify-fs
Drop FileSystem conversion from table::boot::ScopedProtocol
2 parents 77aaf4e + cf52999 commit 24c8117

File tree

5 files changed

+17
-42
lines changed

5 files changed

+17
-42
lines changed

uefi-test-runner/src/boot/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ fn test_load_image(bt: &BootServices) {
9595

9696
// Variant A: FromBuffer
9797
{
98-
let fs = bt
99-
.get_image_file_system(bt.image_handle())
100-
.expect("should open file system");
98+
let fs = boot::get_image_file_system(bt.image_handle()).expect("should open file system");
10199
let path = CString16::try_from(image_device_path_file_path.as_str()).unwrap();
102100
let image_data = FileSystem::new(fs)
103101
.read(&*path)

uefi-test-runner/src/fs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
use alloc::string::{String, ToString};
44
use alloc::vec::Vec;
5+
use uefi::boot::ScopedProtocol;
56
use uefi::fs::{FileSystem, IoError, IoErrorContext, PathBuf};
67
use uefi::proto::media::fs::SimpleFileSystem;
7-
use uefi::table::boot::ScopedProtocol;
88
use uefi::{cstr16, fs, Status};
99

1010
/// Tests functionality from the `uefi::fs` module. This test relies on a

uefi-test-runner/src/proto/media.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use alloc::string::ToString;
22
use core::cell::RefCell;
33
use core::ptr::NonNull;
4-
use uefi::boot;
4+
use uefi::boot::{
5+
self, EventType, OpenProtocolAttributes, OpenProtocolParams, ScopedProtocol, Tpl,
6+
};
57
use uefi::data_types::Align;
68
use uefi::prelude::*;
79
use uefi::proto::media::block::BlockIO;
@@ -11,9 +13,6 @@ use uefi::proto::media::file::{
1113
};
1214
use uefi::proto::media::fs::SimpleFileSystem;
1315
use uefi::proto::media::partition::{MbrOsType, PartitionInfo};
14-
use uefi::table::boot::{
15-
EventType, OpenProtocolAttributes, OpenProtocolParams, ScopedProtocol, Tpl,
16-
};
1716
use uefi::table::runtime::{Daylight, Time, TimeParams};
1817

1918
/// Test directory entry iteration.
@@ -370,8 +369,7 @@ fn find_test_disk(bt: &BootServices) -> (Handle, ScopedProtocol<SimpleFileSystem
370369
assert_eq!(handles.len(), 2);
371370

372371
for handle in handles {
373-
let mut sfs = bt
374-
.open_protocol_exclusive::<SimpleFileSystem>(handle)
372+
let mut sfs = boot::open_protocol_exclusive::<SimpleFileSystem>(handle)
375373
.expect("Failed to get simple file system");
376374
let mut root_directory = sfs.open_volume().unwrap();
377375

uefi/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Changed
44
- **Breaking:** Deleted deprecated function `helpers::system_table`.
5+
- **Breaking:** `FileSystem` no longer has a lifetime parameter, and the
6+
deprecated conversion from `uefi::table::boot::ScopedProtocol` has been
7+
removed.
58

69

710
# uefi - 0.32.0 (2024-09-09)

uefi/src/fs/file_system/fs.rs

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,21 @@ use alloc::vec;
88
use alloc::vec::Vec;
99
use core::fmt;
1010
use core::fmt::{Debug, Formatter};
11-
use core::ops::Deref;
11+
use uefi::boot::ScopedProtocol;
1212

1313
/// Return type for public [`FileSystem`] operations.
1414
pub type FileSystemResult<T> = Result<T, Error>;
1515

16-
/// Contents of the `FileSystem` struct, allowing either variant of
17-
/// `ScopedProtocol` to be used. This is temporary; once `BootServices` and the
18-
/// associated `ScopedProtocol<'a>` structs are removed this inner type can be
19-
/// removed as well.
20-
enum FileSystemInner<'a> {
21-
#[allow(deprecated)]
22-
WithLifetime(uefi::table::boot::ScopedProtocol<'a, SimpleFileSystemProtocol>),
23-
WithoutLifetime(uefi::boot::ScopedProtocol<SimpleFileSystemProtocol>),
24-
}
25-
2616
/// High-level file-system abstraction for UEFI volumes with an API that is
2717
/// close to `std::fs`. It acts as convenient accessor around the
2818
/// [`SimpleFileSystemProtocol`].
2919
///
3020
/// Please refer to the [module documentation] for more information.
3121
///
3222
/// [module documentation]: uefi::fs
33-
pub struct FileSystem<'a>(FileSystemInner<'a>);
23+
pub struct FileSystem(ScopedProtocol<SimpleFileSystemProtocol>);
3424

35-
impl<'a> FileSystem<'a> {
25+
impl FileSystem {
3626
/// Constructor.
3727
#[must_use]
3828
pub fn new(proto: impl Into<Self>) -> Self {
@@ -396,11 +386,7 @@ impl<'a> FileSystem<'a> {
396386

397387
/// Opens a fresh handle to the root directory of the volume.
398388
fn open_root(&mut self) -> FileSystemResult<UefiDirectoryHandle> {
399-
match &mut self.0 {
400-
FileSystemInner::WithLifetime(proto) => proto.open_volume(),
401-
FileSystemInner::WithoutLifetime(proto) => proto.open_volume(),
402-
}
403-
.map_err(|err| {
389+
self.0.open_volume().map_err(|err| {
404390
Error::Io(IoError {
405391
path: {
406392
let mut path = PathBuf::new();
@@ -445,25 +431,15 @@ impl<'a> FileSystem<'a> {
445431
}
446432
}
447433

448-
impl<'a> Debug for FileSystem<'a> {
434+
impl Debug for FileSystem {
449435
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
450-
let ptr: *const _ = match &self.0 {
451-
FileSystemInner::WithLifetime(proto) => proto.deref(),
452-
FileSystemInner::WithoutLifetime(proto) => proto.deref(),
453-
};
436+
let ptr: *const _ = &self.0;
454437
f.debug_tuple("FileSystem").field(&ptr).finish()
455438
}
456439
}
457440

458-
#[allow(deprecated)]
459-
impl<'a> From<uefi::table::boot::ScopedProtocol<'a, SimpleFileSystemProtocol>> for FileSystem<'a> {
460-
fn from(proto: uefi::table::boot::ScopedProtocol<'a, SimpleFileSystemProtocol>) -> Self {
461-
Self(FileSystemInner::WithLifetime(proto))
462-
}
463-
}
464-
465-
impl<'a> From<uefi::boot::ScopedProtocol<SimpleFileSystemProtocol>> for FileSystem<'a> {
441+
impl From<uefi::boot::ScopedProtocol<SimpleFileSystemProtocol>> for FileSystem {
466442
fn from(proto: uefi::boot::ScopedProtocol<SimpleFileSystemProtocol>) -> Self {
467-
Self(FileSystemInner::WithoutLifetime(proto))
443+
Self(proto)
468444
}
469445
}

0 commit comments

Comments
 (0)