Add info() for vfs::FileSystem. Add fs() for vfs::INode.

master
WangRunji 7 years ago
parent d545541d21
commit 383b81411d

@ -306,6 +306,9 @@ impl vfs::INode for INode {
String::from(entry.name.as_ref())
}).collect())
}
fn fs(&self) -> Weak<vfs::FileSystem> {
self.fs.clone()
}
}
impl Drop for INode {
@ -519,6 +522,13 @@ impl vfs::FileSystem for SimpleFileSystem {
fn root_inode(&self) -> Ptr<vfs::INode> {
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 {

@ -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<INodePtr>;
fn lookup(&self, path: &'static str) -> Result<INodePtr>;
fn list(&self) -> Result<Vec<String>>;
// fn io_ctrl(&mut self, op: u32, data: &[u8]) -> Result<()>;
fn fs(&self) -> Weak<FileSystem>;
}
#[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<T> = core::result::Result<T, ()>;
/// 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);
}

Loading…
Cancel
Save