|
|
@ -21,12 +21,12 @@ pub trait INode: Debug {
|
|
|
|
fn sync(&mut self) -> Result<()>;
|
|
|
|
fn sync(&mut self) -> Result<()>;
|
|
|
|
// fn name_file(&mut self) -> Result<()>;
|
|
|
|
// fn name_file(&mut self) -> Result<()>;
|
|
|
|
// fn reclaim(&mut self) -> Result<()>;
|
|
|
|
// fn reclaim(&mut self) -> Result<()>;
|
|
|
|
// fn try_seek(&mut self, offset: u64) -> Result<()>;
|
|
|
|
|
|
|
|
fn resize(&mut self, len: usize) -> Result<()>;
|
|
|
|
fn resize(&mut self, len: usize) -> Result<()>;
|
|
|
|
fn create(&mut self, name: &'static str, type_: FileType) -> Result<INodePtr>;
|
|
|
|
fn create(&mut self, name: &'static str, type_: FileType) -> Result<INodePtr>;
|
|
|
|
fn lookup(&self, path: &'static str) -> Result<INodePtr>;
|
|
|
|
fn lookup(&self, path: &'static str) -> Result<INodePtr>;
|
|
|
|
fn list(&self) -> Result<Vec<String>>;
|
|
|
|
fn list(&self) -> Result<Vec<String>>;
|
|
|
|
// fn io_ctrl(&mut self, op: u32, data: &[u8]) -> Result<()>;
|
|
|
|
// fn io_ctrl(&mut self, op: u32, data: &[u8]) -> Result<()>;
|
|
|
|
|
|
|
|
fn fs(&self) -> Weak<FileSystem>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
|
@ -42,12 +42,18 @@ pub enum FileType {
|
|
|
|
File, Dir,
|
|
|
|
File, Dir,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
|
|
|
pub struct FsInfo {
|
|
|
|
|
|
|
|
pub max_file_size: usize,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub type Result<T> = core::result::Result<T, ()>;
|
|
|
|
pub type Result<T> = core::result::Result<T, ()>;
|
|
|
|
|
|
|
|
|
|
|
|
/// Abstract filesystem
|
|
|
|
/// Abstract filesystem
|
|
|
|
pub trait FileSystem {
|
|
|
|
pub trait FileSystem {
|
|
|
|
fn sync(&self) -> Result<()>;
|
|
|
|
fn sync(&self) -> Result<()>;
|
|
|
|
fn root_inode(&self) -> INodePtr;
|
|
|
|
fn root_inode(&self) -> INodePtr;
|
|
|
|
|
|
|
|
fn info(&self) -> &'static FsInfo;
|
|
|
|
// fn unmount(&self) -> Result<()>;
|
|
|
|
// fn unmount(&self) -> Result<()>;
|
|
|
|
// fn cleanup(&self);
|
|
|
|
// fn cleanup(&self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|