use ext2::{ fs::{ sync::{Inode, Synced}, Ext2, }, sector::{SectorSize, Size1024}, volume::Volume, }; use spin::Lazy; pub static FILE_SYSTEM: Lazy>>>> = Lazy::new(|| spin::Mutex::new(load_fs())); pub fn walk>( fs: &Synced>, inode: Inode, name: String, ) { if let Some(dir) = inode.directory() { for entry in dir { assert!(entry.is_ok()); let entry = entry.unwrap(); let entry_name = String::from_utf8_lossy(&entry.name); println!("{}/{} => {}", name, entry_name, entry.inode,); if entry_name != "." && entry_name != ".." { walk( fs, fs.inode_nth(entry.inode).unwrap(), format!("{}/{}", name, entry_name), ); } } } } fn load_fs() -> Synced>> { let mut volume = Vec::new(); volume.extend_from_slice(include_bytes!("../../../userland/root_fs/ext2.img")); Synced::>::new(volume).unwrap() }