Skip to content

Commit 49fefcb

Browse files
uefi: Use uefi-raw's file_system module
1 parent 330ac9f commit 49fefcb

File tree

3 files changed

+13
-36
lines changed

3 files changed

+13
-36
lines changed

uefi/src/proto/media/file/info.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::FileAttribute;
22
use crate::data_types::Align;
33
use crate::table::runtime::Time;
4-
use crate::{guid, CStr16, Char16, Guid, Identify};
4+
use crate::{CStr16, Char16, Guid, Identify};
55
use core::ffi::c_void;
66
use core::fmt::{self, Display, Formatter};
77
use core::{mem, ptr};
@@ -266,7 +266,7 @@ impl Align for FileInfo {
266266
}
267267

268268
unsafe impl Identify for FileInfo {
269-
const GUID: Guid = guid!("09576e92-6d3f-11d2-8e39-00a0c969723b");
269+
const GUID: Guid = uefi_raw::protocol::file_system::FileInfo::ID;
270270
}
271271

272272
impl InfoInternal for FileInfo {
@@ -361,7 +361,7 @@ impl Align for FileSystemInfo {
361361
}
362362

363363
unsafe impl Identify for FileSystemInfo {
364-
const GUID: Guid = guid!("09576e93-6d3f-11d2-8e39-00a0c969723b");
364+
const GUID: Guid = uefi_raw::protocol::file_system::FileSystemInfo::ID;
365365
}
366366

367367
impl InfoInternal for FileSystemInfo {
@@ -412,7 +412,7 @@ impl Align for FileSystemVolumeLabel {
412412
}
413413

414414
unsafe impl Identify for FileSystemVolumeLabel {
415-
const GUID: Guid = guid!("db47d7d3-fe81-11d3-9a35-0090273fc14d");
415+
const GUID: Guid = uefi_raw::protocol::file_system::FileSystemVolumeLabel::ID;
416416
}
417417

418418
impl InfoInternal for FileSystemVolumeLabel {

uefi/src/proto/media/file/mod.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod info;
1111
mod regular;
1212

1313
use crate::{CStr16, Char16, Guid, Result, Status, StatusExt};
14-
use bitflags::bitflags;
1514
use core::ffi::c_void;
1615
use core::fmt::Debug;
1716
use core::{mem, ptr};
@@ -26,6 +25,7 @@ pub use self::info::{
2625
FromUefi,
2726
};
2827
pub use self::regular::RegularFile;
28+
pub use uefi_raw::protocol::file_system::FileAttribute;
2929

3030
/// Common interface to `FileHandle`, `RegularFile`, and `Directory`.
3131
///
@@ -395,26 +395,6 @@ pub enum FileMode {
395395
CreateReadWrite = (1 << 63) | 2 | 1,
396396
}
397397

398-
bitflags! {
399-
/// Attributes describing the properties of a file on the file system.
400-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
401-
#[repr(transparent)]
402-
pub struct FileAttribute: u64 {
403-
/// File can only be opened in [`FileMode::READ`] mode.
404-
const READ_ONLY = 1;
405-
/// Hidden file, not normally visible to the user.
406-
const HIDDEN = 1 << 1;
407-
/// System file, indicates this file is an internal operating system file.
408-
const SYSTEM = 1 << 2;
409-
/// This file is a directory.
410-
const DIRECTORY = 1 << 4;
411-
/// This file is compressed.
412-
const ARCHIVE = 1 << 5;
413-
/// Mask combining all the valid attributes.
414-
const VALID_ATTR = 0x37;
415-
}
416-
}
417-
418398
#[cfg(test)]
419399
mod tests {
420400
use super::*;

uefi/src/proto/media/fs.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! File system support protocols.
22
3-
use super::file::{Directory, FileHandle, FileImpl};
3+
use super::file::{Directory, FileHandle};
44
use crate::proto::unsafe_protocol;
5-
use crate::{Result, Status, StatusExt};
5+
use crate::{Result, StatusExt};
66
use core::ptr;
7+
use uefi_raw::protocol::file_system::SimpleFileSystemProtocol;
78

89
/// Allows access to a FAT-12/16/32 file system.
910
///
@@ -20,13 +21,9 @@ use core::ptr;
2021
/// [`BootServices::get_image_file_system`]: crate::table::boot::BootServices::get_image_file_system
2122
/// [`BootServices`]: crate::table::boot::BootServices#accessing-protocols
2223
#[derive(Debug)]
23-
#[repr(C)]
24-
#[unsafe_protocol("964e5b22-6459-11d2-8e39-00a0c969723b")]
25-
pub struct SimpleFileSystem {
26-
revision: u64,
27-
open_volume:
28-
extern "efiapi" fn(this: &mut SimpleFileSystem, root: &mut *mut FileImpl) -> Status,
29-
}
24+
#[repr(transparent)]
25+
#[unsafe_protocol(SimpleFileSystemProtocol::GUID)]
26+
pub struct SimpleFileSystem(SimpleFileSystemProtocol);
3027

3128
impl SimpleFileSystem {
3229
/// Open the root directory on a volume.
@@ -49,7 +46,7 @@ impl SimpleFileSystem {
4946
/// * [`uefi::Status::MEDIA_CHANGED`]
5047
pub fn open_volume(&mut self) -> Result<Directory> {
5148
let mut ptr = ptr::null_mut();
52-
(self.open_volume)(self, &mut ptr)
53-
.to_result_with_val(|| unsafe { Directory::new(FileHandle::new(ptr)) })
49+
unsafe { (self.0.open_volume)(&mut self.0, &mut ptr) }
50+
.to_result_with_val(|| unsafe { Directory::new(FileHandle::new(ptr.cast())) })
5451
}
5552
}

0 commit comments

Comments
 (0)