From 40b4191d2df304cb2b6b6c12db3eb4b83553e757 Mon Sep 17 00:00:00 2001 From: Julien CLEMENT Date: Sun, 25 Dec 2022 14:24:09 +0100 Subject: [PATCH] remove ;1 at the end of file identifiers Signed-off-by: Julien CLEMENT --- src/fs/iso/iso9660.rs | 10 +++++++++- src/fs/iso/mod.rs | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/fs/iso/iso9660.rs b/src/fs/iso/iso9660.rs index 726f6d7..34afb61 100644 --- a/src/fs/iso/iso9660.rs +++ b/src/fs/iso/iso9660.rs @@ -73,7 +73,15 @@ pub struct IsoDir { impl IsoDir { #[allow(unaligned_references)] pub fn get_idf(&self) -> &[u8] { - unsafe { core::slice::from_raw_parts(self.idf.as_ptr(), self.idf_len as usize) } + let mut len: usize = self.idf_len as usize; + unsafe { + let mut idf = core::slice::from_raw_parts(self.idf.as_ptr(), len as usize); + if len > 2 && idf[len - 2] == b';' && idf[len - 1] == b'1' { + len -= 2; + idf = core::slice::from_raw_parts(self.idf.as_ptr(), len as usize); + } + idf + } } pub fn next_entry(&self) -> &IsoDir { diff --git a/src/fs/iso/mod.rs b/src/fs/iso/mod.rs index 6587016..73e2ae0 100644 --- a/src/fs/iso/mod.rs +++ b/src/fs/iso/mod.rs @@ -42,12 +42,15 @@ impl FileSystem for IsoFS { .filter(|p| p != &""); for path_component in path_it { + let mut found = false; while curr_entry.idf_len != 0 { serial_println!("{:?}", curr_entry.idf_len); serial_println!("{:?}", alloc::str::from_utf8(curr_entry.get_idf()).unwrap()); + // Found entry if curr_entry.matches(path_component) { serial_println!("Found {}", path_component); + found = true; curr_entry_block = read_block(curr_entry.data_blk.le).await; curr_entry = unserialize(curr_entry_block.as_ptr()); break; @@ -56,6 +59,9 @@ impl FileSystem for IsoFS { // Next entry curr_entry = curr_entry.next_entry(); } + if !found { + return None; + } } let fd = IsoFD::new();