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();