Compare commits
No commits in common. "2e7415e1e61302809556bdd5b52a18be927da22c" and "d4add50d826b7f6b2f6253eec1a7e4718dcf9cf9" have entirely different histories.
2e7415e1e6
...
d4add50d82
@ -325,7 +325,3 @@ pub async fn print_block(lba: u32) {
|
||||
let block = DRIVE.lock().await.as_mut().unwrap().read_block(lba).await;
|
||||
serial_println!("{:x?}", block);
|
||||
}
|
||||
|
||||
pub async fn read_block(lba: u32) -> [u8; CD_SECTOR_SIZE] {
|
||||
DRIVE.lock().await.as_mut().unwrap().read_block(lba).await
|
||||
}
|
@ -75,14 +75,6 @@ impl IsoDir {
|
||||
pub fn get_idf(&self) -> &[u8] {
|
||||
unsafe { core::slice::from_raw_parts(self.idf.as_ptr(), self.idf_len as usize) }
|
||||
}
|
||||
|
||||
pub fn next_entry(&self) -> &IsoDir {
|
||||
crate::utils::ref_raw_offset(self, self.dir_size as isize)
|
||||
}
|
||||
|
||||
pub fn matches(&self, path: &str) -> bool {
|
||||
self.get_idf() == path.as_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
// Primary volume descriptor structure
|
||||
|
@ -1,7 +1,7 @@
|
||||
mod fd;
|
||||
pub mod iso9660;
|
||||
|
||||
use crate::drivers::atapi::read_block;
|
||||
use crate::drivers::atapi::DRIVE;
|
||||
use crate::fd::{FDt, FD_TABLE};
|
||||
use crate::println;
|
||||
use crate::serial_println;
|
||||
@ -32,7 +32,13 @@ impl FileSystem for IsoFS {
|
||||
}
|
||||
|
||||
let root: IsoDir = voldesc.root_dir;
|
||||
let mut curr_entry_block: [u8; iso9660::ISO_BLOCK_SIZE] = read_block(root.data_blk.le).await;
|
||||
let mut curr_entry_block: [u8; iso9660::ISO_BLOCK_SIZE] = DRIVE
|
||||
.lock()
|
||||
.await
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.read_block(root.data_blk.le)
|
||||
.await;
|
||||
|
||||
let mut curr_entry: &IsoDir = unserialize(curr_entry_block.as_ptr());
|
||||
|
||||
@ -46,15 +52,24 @@ impl FileSystem for IsoFS {
|
||||
serial_println!("{:?}", curr_entry.idf_len);
|
||||
serial_println!("{:?}", alloc::str::from_utf8(curr_entry.get_idf()).unwrap());
|
||||
|
||||
if curr_entry.matches(path_component) {
|
||||
if curr_entry.get_idf() == path_component.as_bytes() {
|
||||
serial_println!("Found {}", path_component);
|
||||
curr_entry_block = read_block(curr_entry.data_blk.le).await;
|
||||
curr_entry_block = DRIVE
|
||||
.lock()
|
||||
.await
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.read_block(curr_entry.data_blk.le)
|
||||
.await;
|
||||
curr_entry = unserialize(curr_entry_block.as_ptr());
|
||||
break;
|
||||
}
|
||||
|
||||
// Next entry
|
||||
curr_entry = curr_entry.next_entry();
|
||||
unsafe {
|
||||
let curr_ptr: *const IsoDir = curr_entry;
|
||||
curr_entry = &*curr_ptr.cast::<u8>().offset(curr_entry.dir_size as isize).cast::<IsoDir>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,8 +79,13 @@ impl FileSystem for IsoFS {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
|
||||
let desc_block = read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK).await;
|
||||
let desc_block = DRIVE
|
||||
.lock()
|
||||
.await
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK)
|
||||
.await;
|
||||
*unserialize::<IsoPrimVolDesc>(desc_block.as_ptr())
|
||||
}
|
||||
|
@ -3,17 +3,3 @@ pub mod serialize;
|
||||
|
||||
pub use mutex::AsyncMutex;
|
||||
pub use serialize::unserialize;
|
||||
|
||||
pub fn ref_offset<T>(r: &T, off: isize) -> &T {
|
||||
let ref_ptr: *const T = r;
|
||||
unsafe {
|
||||
return &*ref_ptr.offset(off);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ref_raw_offset<T>(r: &T, off: isize) -> &T {
|
||||
let ref_ptr: *const T = r;
|
||||
unsafe {
|
||||
return &*ref_ptr.cast::<u8>().offset(off).cast::<T>();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user