Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/uefi/src/proto/media/fs.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / uefi / src / proto / media / fs.rs` 61 lines ยท 2120 bytes Raw Blame History 1 // SPDX-License-Identifier: MIT OR Apache-2.0 2 3 //! File system support protocols. 4 5 use super::file::{Directory, FileHandle}; 6 use crate::proto::unsafe_protocol; 7 use crate::{Result, StatusExt}; 8 use core::ptr; 9 use uefi_raw::protocol::file_system::SimpleFileSystemProtocol; 10 11 #[cfg(doc)] 12 use crate::Status; 13 14 /// Simple File System [`Protocol`]. Allows access to a FAT-12/16/32 file 15 /// system. 16 /// 17 /// This interface is implemented by some storage devices 18 /// to allow file access to the contained file systems. 19 /// 20 /// # Accessing `SimpleFileSystem` protocol 21 /// 22 /// Use [`boot::get_image_file_system`] to retrieve the `SimpleFileSystem` 23 /// protocol associated with a given image handle. 24 /// 25 /// See the [`boot`] documentation for more details of how to open a protocol. 26 /// 27 /// [`boot::get_image_file_system`]: crate::boot::get_image_file_system 28 /// [`boot`]: crate::boot#accessing-protocols 29 /// [`Protocol`]: uefi::proto::Protocol 30 #[derive(Debug)] 31 #[repr(transparent)] 32 #[unsafe_protocol(SimpleFileSystemProtocol::GUID)] 33 pub struct SimpleFileSystem(SimpleFileSystemProtocol); 34 35 impl SimpleFileSystem { 36 /// Open the root directory on a volume. 37 /// 38 /// # Errors 39 /// 40 /// See section `EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume()` in the UEFI Specification 41 /// for more details. 42 /// 43 /// If you can't find the function definition, try searching for 44 /// `EFI_SIMPLE_FILE SYSTEM_PROTOCOL.OpenVolume()` (this has a space in between FILE and 45 /// SYSTEM; it could be a typo in the UEFI spec). 46 /// 47 /// * [`Status::UNSUPPORTED`] 48 /// * [`Status::NO_MEDIA`] 49 /// * [`Status::DEVICE_ERROR`] 50 /// * [`Status::VOLUME_CORRUPTED`] 51 /// * [`Status::ACCESS_DENIED`] 52 /// * [`Status::OUT_OF_RESOURCES`] 53 /// * [`Status::MEDIA_CHANGED`] 54 pub fn open_volume(&mut self) -> Result { 55 let mut ptr = ptr::null_mut(); 56 // SAFETY: The memory is valid. 57 unsafe { (self.0.open_volume)(&mut self.0, &mut ptr) } 58 // SAFETY: The memory is valid. 59 .to_result_with_val(|| unsafe { Directory::new(FileHandle::new(ptr.cast())) }) 60 } 61 }