use { alloc::{format, string::String, vec::Vec}, ext2::{ fs::{ sync::{Inode, Synced}, Ext2, }, sector::{SectorSize, Size1024}, volume::Volume, }, }; fn load_fs() -> Synced>> { let mut volume = Vec::new(); volume.extend_from_slice(include_bytes!("../../../userland/root_rs/ext2.img")); let fs = Synced::>::new(volume).unwrap(); fs } // use serde::__private::from_utf8_lossy; pub fn walk<'vol, S: SectorSize, V: Volume>( fs: &'vol Synced>, inode: Inode, name: String, ) { inode.directory().map(|dir| { 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), ); } } }); } lazy_static::lazy_static!( pub static ref FILE_SYSTEM:spin::Mutex>>>= spin::Mutex::new(load_fs()); );