diff --git a/src/sfs.rs b/src/sfs.rs index c143ae2..ae02b9c 100644 --- a/src/sfs.rs +++ b/src/sfs.rs @@ -306,6 +306,9 @@ impl vfs::INode for INode { String::from(entry.name.as_ref()) }).collect()) } + fn fs(&self) -> Weak { + self.fs.clone() + } } impl Drop for INode { @@ -519,6 +522,13 @@ impl vfs::FileSystem for SimpleFileSystem { fn root_inode(&self) -> Ptr { self.get_inode(BLKN_ROOT) } + + fn info(&self) -> &'static vfs::FsInfo { + static INFO: vfs::FsInfo = vfs::FsInfo { + max_file_size: MAX_FILE_SIZE, + }; + &INFO + } } impl Drop for SimpleFileSystem { diff --git a/src/vfs.rs b/src/vfs.rs index b58e77e..be0c2a6 100644 --- a/src/vfs.rs +++ b/src/vfs.rs @@ -21,12 +21,12 @@ pub trait INode: Debug { fn sync(&mut self) -> Result<()>; // fn name_file(&mut self) -> Result<()>; // fn reclaim(&mut self) -> Result<()>; -// fn try_seek(&mut self, offset: u64) -> Result<()>; fn resize(&mut self, len: usize) -> Result<()>; fn create(&mut self, name: &'static str, type_: FileType) -> Result; fn lookup(&self, path: &'static str) -> Result; fn list(&self) -> Result>; // fn io_ctrl(&mut self, op: u32, data: &[u8]) -> Result<()>; + fn fs(&self) -> Weak; } #[derive(Debug, Eq, PartialEq)] @@ -42,12 +42,18 @@ pub enum FileType { File, Dir, } +#[derive(Debug)] +pub struct FsInfo { + pub max_file_size: usize, +} + pub type Result = core::result::Result; /// Abstract filesystem pub trait FileSystem { fn sync(&self) -> Result<()>; fn root_inode(&self) -> INodePtr; + fn info(&self) -> &'static FsInfo; // fn unmount(&self) -> Result<()>; // fn cleanup(&self); }