diff --git a/src/efi/file.rs b/src/efi/file.rs index ce2b6a42..8d10b1bd 100644 --- a/src/efi/file.rs +++ b/src/efi/file.rs @@ -106,7 +106,7 @@ pub extern "efiapi" fn read(file: *mut FileProtocol, size: *mut usize, buf: *mut Err(_) => return Status::DEVICE_ERROR, }; - let (node, name) = match d.next_node() { + let (node, mut name) = match d.next_node() { Ok(node) => node, Err(crate::fat::Error::EndOfFile) => { unsafe { *size = 0 }; @@ -115,6 +115,15 @@ pub extern "efiapi" fn read(file: *mut FileProtocol, size: *mut usize, buf: *mut Err(_) => return Status::DEVICE_ERROR, }; + // Fixup for Director or file name, when the length of its name and extend name equals 11. There maybe no + // separation between them. If so, add it. + if name[10] >= b'a' && name[10] <= b'z' || name[10] >= b'A' && name[10] <= b'Z' && name[8] != b' ' && name[8] != b'.' { + name[11] = name[10]; + name[10] = name[9]; + name[9] = name[8]; + name[8] = b'.'; + } + let attribute = match &node { crate::fat::Node::Directory(_) => r_efi::protocols::file::DIRECTORY, crate::fat::Node::File(_) => r_efi::protocols::file::ARCHIVE, diff --git a/src/fat.rs b/src/fat.rs index 93d003d7..bb3ad239 100644 --- a/src/fat.rs +++ b/src/fat.rs @@ -403,9 +403,9 @@ impl<'a> Directory<'a> { } } - pub fn next_node(&mut self) -> Result<(Node, [u8; 11]), Error> { + pub fn next_node(&mut self) -> Result<(Node, [u8; 12]), Error> { let de = self.next_entry()?; - let mut name = [0_u8; 11]; + let mut name = [0_u8; 12]; name_to_str(core::str::from_utf8(&de.name).unwrap(), &mut name); match de.file_type {