add explicit 'dyn'

master
WangRunji 5 years ago
parent 51cbe5c129
commit 29096ccb61

@ -23,7 +23,7 @@ use rcore_fs::vfs;
#[derive(Clone)] #[derive(Clone)]
struct Ext2Volume { struct Ext2Volume {
inner: Arc<Device>, inner: Arc<dyn Device>,
} }
#[derive(Clone)] #[derive(Clone)]
@ -67,11 +67,11 @@ impl core::convert::From<DevError> for Ext2Error {
} }
impl Ext2FileSystem { impl Ext2FileSystem {
pub fn open(device: Arc<Device>) -> vfs::Result<Arc<Self>> { pub fn open(device: Arc<dyn Device>) -> vfs::Result<Arc<Self>> {
Ok(Self::open_internal(device)?) Ok(Self::open_internal(device)?)
} }
fn open_internal(device: Arc<Device>) -> Result<Arc<Self>, Ext2Error> { fn open_internal(device: Arc<dyn Device>) -> Result<Arc<Self>, Ext2Error> {
let volume = Ext2Volume { inner: device }; let volume = Ext2Volume { inner: device };
let fs = Synced::new(volume.clone())?; let fs = Synced::new(volume.clone())?;
Ok(Arc::new(Ext2FileSystem { inner: fs, volume })) Ok(Arc::new(Ext2FileSystem { inner: fs, volume }))

@ -9,9 +9,9 @@ use rcore_fs::vfs::FileSystem;
#[cfg(feature = "use_fuse")] #[cfg(feature = "use_fuse")]
use rcore_fs_fuse::fuse::VfsFuse; use rcore_fs_fuse::fuse::VfsFuse;
use rcore_fs_fuse::zip::{unzip_dir, zip_dir}; use rcore_fs_fuse::zip::{unzip_dir, zip_dir};
use rcore_fs_ramfs as ramfs;
use rcore_fs_sefs as sefs; use rcore_fs_sefs as sefs;
use rcore_fs_sfs as sfs; use rcore_fs_sfs as sfs;
use rcore_fs_ramfs as ramfs;
use git_version::git_version; use git_version::git_version;
@ -69,7 +69,7 @@ fn main() {
} }
}; };
let fs: Arc<FileSystem> = match opt.fs.as_str() { let fs: Arc<dyn FileSystem> = match opt.fs.as_str() {
"sfs" => { "sfs" => {
let file = OpenOptions::new() let file = OpenOptions::new()
.read(true) .read(true)
@ -96,9 +96,7 @@ fn main() {
.expect("failed to open sefs"), .expect("failed to open sefs"),
} }
} }
"ramfs" => { "ramfs" => ramfs::RamFS::new(),
ramfs::RamFS::new()
}
_ => panic!("unsupported file system"), _ => panic!("unsupported file system"),
}; };
match opt.cmd { match opt.cmd {

@ -12,7 +12,7 @@ use rcore_fs::vfs::{FileType, INode};
const DEFAULT_MODE: u32 = 0o664; const DEFAULT_MODE: u32 = 0o664;
const BUF_SIZE: usize = 0x1000; const BUF_SIZE: usize = 0x1000;
pub fn zip_dir(path: &Path, inode: Arc<INode>) -> Result<(), Box<Error>> { pub fn zip_dir(path: &Path, inode: Arc<dyn INode>) -> Result<(), Box<dyn Error>> {
let dir = fs::read_dir(path)?; let dir = fs::read_dir(path)?;
for entry in dir { for entry in dir {
let entry = entry?; let entry = entry?;
@ -45,7 +45,7 @@ pub fn zip_dir(path: &Path, inode: Arc<INode>) -> Result<(), Box<Error>> {
Ok(()) Ok(())
} }
pub fn unzip_dir(path: &Path, inode: Arc<INode>) -> Result<(), Box<Error>> { pub fn unzip_dir(path: &Path, inode: Arc<dyn INode>) -> Result<(), Box<dyn Error>> {
let files = inode.list()?; let files = inode.list()?;
for name in files.iter().skip(2) { for name in files.iter().skip(2) {
let inode = inode.lookup(name.as_str())?; let inode = inode.lookup(name.as_str())?;

@ -36,8 +36,8 @@ pub trait File: Send + Sync {
/// The collection of all files in the FS. /// The collection of all files in the FS.
pub trait Storage: Send + Sync { pub trait Storage: Send + Sync {
fn open(&self, file_id: usize) -> DevResult<Box<File>>; fn open(&self, file_id: usize) -> DevResult<Box<dyn File>>;
fn create(&self, file_id: usize) -> DevResult<Box<File>>; fn create(&self, file_id: usize) -> DevResult<Box<dyn File>>;
fn remove(&self, file_id: usize) -> DevResult<()>; fn remove(&self, file_id: usize) -> DevResult<()>;
} }

@ -20,14 +20,14 @@ impl StdStorage {
} }
impl super::Storage for StdStorage { impl super::Storage for StdStorage {
fn open(&self, file_id: usize) -> DevResult<Box<super::File>> { fn open(&self, file_id: usize) -> DevResult<Box<dyn super::File>> {
let mut path = self.path.to_path_buf(); let mut path = self.path.to_path_buf();
path.push(format!("{}", file_id)); path.push(format!("{}", file_id));
let file = OpenOptions::new().read(true).write(true).open(path)?; let file = OpenOptions::new().read(true).write(true).open(path)?;
Ok(Box::new(Mutex::new(file))) Ok(Box::new(Mutex::new(file)))
} }
fn create(&self, file_id: usize) -> DevResult<Box<super::File>> { fn create(&self, file_id: usize) -> DevResult<Box<dyn super::File>> {
let mut path = self.path.to_path_buf(); let mut path = self.path.to_path_buf();
path.push(format!("{}", file_id)); path.push(format!("{}", file_id));
let file = OpenOptions::new() let file = OpenOptions::new()

@ -28,7 +28,7 @@ pub mod dev;
mod structs; mod structs;
/// Helper methods for `File` /// Helper methods for `File`
impl File { impl dyn File {
fn read_block(&self, id: BlockId, buf: &mut [u8]) -> DevResult<()> { fn read_block(&self, id: BlockId, buf: &mut [u8]) -> DevResult<()> {
assert!(buf.len() <= BLKSIZE); assert!(buf.len() <= BLKSIZE);
self.read_exact_at(buf, id * BLKSIZE) self.read_exact_at(buf, id * BLKSIZE)
@ -60,7 +60,7 @@ pub struct INodeImpl {
/// on-disk inode /// on-disk inode
disk_inode: RwLock<Dirty<DiskINode>>, disk_inode: RwLock<Dirty<DiskINode>>,
/// back file /// back file
file: Box<File>, file: Box<dyn File>,
/// Reference to FS /// Reference to FS
fs: Arc<SEFS>, fs: Arc<SEFS>,
} }
@ -232,7 +232,12 @@ impl vfs::INode for INodeImpl {
self.disk_inode.write().size = len as u32; self.disk_inode.write().size = len as u32;
Ok(()) Ok(())
} }
fn create(&self, name: &str, type_: vfs::FileType, mode: u32) -> vfs::Result<Arc<vfs::INode>> { fn create(
&self,
name: &str,
type_: vfs::FileType,
mode: u32,
) -> vfs::Result<Arc<dyn vfs::INode>> {
let type_ = match type_ { let type_ = match type_ {
vfs::FileType::File => FileType::File, vfs::FileType::File => FileType::File,
vfs::FileType::Dir => FileType::Dir, vfs::FileType::Dir => FileType::Dir,
@ -309,7 +314,7 @@ impl vfs::INode for INodeImpl {
Ok(()) Ok(())
} }
fn link(&self, name: &str, other: &Arc<INode>) -> vfs::Result<()> { fn link(&self, name: &str, other: &Arc<dyn INode>) -> vfs::Result<()> {
let info = self.metadata()?; let info = self.metadata()?;
if info.type_ != vfs::FileType::Dir { if info.type_ != vfs::FileType::Dir {
return Err(FsError::NotDir); return Err(FsError::NotDir);
@ -337,7 +342,7 @@ impl vfs::INode for INodeImpl {
child.nlinks_inc(); child.nlinks_inc();
Ok(()) Ok(())
} }
fn move_(&self, old_name: &str, target: &Arc<INode>, new_name: &str) -> vfs::Result<()> { fn move_(&self, old_name: &str, target: &Arc<dyn INode>, new_name: &str) -> vfs::Result<()> {
let info = self.metadata()?; let info = self.metadata()?;
if info.type_ != vfs::FileType::Dir { if info.type_ != vfs::FileType::Dir {
return Err(FsError::NotDir); return Err(FsError::NotDir);
@ -398,7 +403,7 @@ impl vfs::INode for INodeImpl {
Ok(()) Ok(())
} }
fn find(&self, name: &str) -> vfs::Result<Arc<vfs::INode>> { fn find(&self, name: &str) -> vfs::Result<Arc<dyn vfs::INode>> {
let info = self.metadata()?; let info = self.metadata()?;
if info.type_ != vfs::FileType::Dir { if info.type_ != vfs::FileType::Dir {
return Err(FsError::NotDir); return Err(FsError::NotDir);
@ -419,10 +424,10 @@ impl vfs::INode for INodeImpl {
fn io_control(&self, _cmd: u32, _data: usize) -> vfs::Result<()> { fn io_control(&self, _cmd: u32, _data: usize) -> vfs::Result<()> {
Err(FsError::NotSupported) Err(FsError::NotSupported)
} }
fn fs(&self) -> Arc<vfs::FileSystem> { fn fs(&self) -> Arc<dyn vfs::FileSystem> {
self.fs.clone() self.fs.clone()
} }
fn as_any_ref(&self) -> &Any { fn as_any_ref(&self) -> &dyn Any {
self self
} }
} }
@ -449,11 +454,11 @@ pub struct SEFS {
/// inode list /// inode list
inodes: RwLock<BTreeMap<INodeId, Weak<INodeImpl>>>, inodes: RwLock<BTreeMap<INodeId, Weak<INodeImpl>>>,
/// device /// device
device: Box<Storage>, device: Box<dyn Storage>,
/// metadata file /// metadata file
meta_file: Box<File>, meta_file: Box<dyn File>,
/// Time provider /// Time provider
time_provider: &'static TimeProvider, time_provider: &'static dyn TimeProvider,
/// Pointer to self, used by INodes /// Pointer to self, used by INodes
self_ptr: Weak<SEFS>, self_ptr: Weak<SEFS>,
} }
@ -461,8 +466,8 @@ pub struct SEFS {
impl SEFS { impl SEFS {
/// Load SEFS /// Load SEFS
pub fn open( pub fn open(
device: Box<Storage>, device: Box<dyn Storage>,
time_provider: &'static TimeProvider, time_provider: &'static dyn TimeProvider,
) -> vfs::Result<Arc<Self>> { ) -> vfs::Result<Arc<Self>> {
let meta_file = device.open(0)?; let meta_file = device.open(0)?;
let super_block = meta_file.load_struct::<SuperBlock>(BLKN_SUPER)?; let super_block = meta_file.load_struct::<SuperBlock>(BLKN_SUPER)?;
@ -496,8 +501,8 @@ impl SEFS {
} }
/// Create a new SEFS /// Create a new SEFS
pub fn create( pub fn create(
device: Box<Storage>, device: Box<dyn Storage>,
time_provider: &'static TimeProvider, time_provider: &'static dyn TimeProvider,
) -> vfs::Result<Arc<Self>> { ) -> vfs::Result<Arc<Self>> {
let blocks = BLKBITS; let blocks = BLKBITS;
@ -683,7 +688,7 @@ impl vfs::FileSystem for SEFS {
Ok(()) Ok(())
} }
fn root_inode(&self) -> Arc<vfs::INode> { fn root_inode(&self) -> Arc<dyn vfs::INode> {
self.get_inode(BLKN_ROOT) self.get_inode(BLKN_ROOT)
} }

@ -7,7 +7,6 @@ extern crate alloc;
extern crate log; extern crate log;
use alloc::{ use alloc::{
boxed::Box,
collections::BTreeMap, collections::BTreeMap,
string::String, string::String,
sync::{Arc, Weak}, sync::{Arc, Weak},
@ -19,7 +18,7 @@ use core::fmt::{Debug, Error, Formatter};
use core::mem::uninitialized; use core::mem::uninitialized;
use bitvec::BitVec; use bitvec::BitVec;
use spin::{RwLock, RwLockReadGuard, RwLockWriteGuard}; use spin::RwLock;
use rcore_fs::dev::Device; use rcore_fs::dev::Device;
use rcore_fs::dirty::Dirty; use rcore_fs::dirty::Dirty;
@ -55,7 +54,7 @@ trait DeviceExt: Device {
} }
} }
impl DeviceExt for Device {} impl DeviceExt for dyn Device {}
/// INode for SFS /// INode for SFS
pub struct INodeImpl { pub struct INodeImpl {
@ -322,7 +321,7 @@ impl INodeImpl {
/// Read/Write content, no matter what type it is /// Read/Write content, no matter what type it is
fn _io_at<F>(&self, begin: usize, end: usize, mut f: F) -> vfs::Result<usize> fn _io_at<F>(&self, begin: usize, end: usize, mut f: F) -> vfs::Result<usize>
where where
F: FnMut(&Arc<Device>, &BlockRange, usize) -> vfs::Result<()>, F: FnMut(&Arc<dyn Device>, &BlockRange, usize) -> vfs::Result<()>,
{ {
let size = self.disk_inode.read().size as usize; let size = self.disk_inode.read().size as usize;
let iter = BlockIter { let iter = BlockIter {
@ -394,7 +393,7 @@ impl INodeImpl {
id: child.id as u32, id: child.id as u32,
name: Str256::from(name), name: Str256::from(name),
}; };
let mut disk_inode = self.disk_inode.write(); let disk_inode = self.disk_inode.write();
let old_size = disk_inode.size as usize; let old_size = disk_inode.size as usize;
self._resize(old_size + BLKSIZE)?; self._resize(old_size + BLKSIZE)?;
self._write_at(old_size, entry.as_buf()).unwrap(); self._write_at(old_size, entry.as_buf()).unwrap();
@ -498,7 +497,13 @@ impl vfs::INode for INodeImpl {
} }
self._resize(len) self._resize(len)
} }
fn create2(&self, name: &str, type_: vfs::FileType, _mode: u32, data: usize)->vfs::Result<Arc<vfs::INode>>{ fn create2(
&self,
name: &str,
type_: vfs::FileType,
_mode: u32,
data: usize,
) -> vfs::Result<Arc<dyn vfs::INode>> {
let info = self.metadata()?; let info = self.metadata()?;
if info.type_ != vfs::FileType::Dir { if info.type_ != vfs::FileType::Dir {
return Err(FsError::NotDir); return Err(FsError::NotDir);
@ -535,7 +540,7 @@ impl vfs::INode for INodeImpl {
Ok(inode) Ok(inode)
} }
fn link(&self, name: &str, other: &Arc<INode>) -> vfs::Result<()> { fn link(&self, name: &str, other: &Arc<dyn INode>) -> vfs::Result<()> {
let info = self.metadata()?; let info = self.metadata()?;
if info.type_ != vfs::FileType::Dir { if info.type_ != vfs::FileType::Dir {
return Err(FsError::NotDir); return Err(FsError::NotDir);
@ -598,7 +603,7 @@ impl vfs::INode for INodeImpl {
Ok(()) Ok(())
} }
fn move_(&self, old_name: &str, target: &Arc<INode>, new_name: &str) -> vfs::Result<()> { fn move_(&self, old_name: &str, target: &Arc<dyn INode>, new_name: &str) -> vfs::Result<()> {
let info = self.metadata()?; let info = self.metadata()?;
if info.type_ != vfs::FileType::Dir { if info.type_ != vfs::FileType::Dir {
return Err(FsError::NotDir); return Err(FsError::NotDir);
@ -658,7 +663,7 @@ impl vfs::INode for INodeImpl {
} }
Ok(()) Ok(())
} }
fn find(&self, name: &str) -> vfs::Result<Arc<vfs::INode>> { fn find(&self, name: &str) -> vfs::Result<Arc<dyn vfs::INode>> {
let info = self.metadata()?; let info = self.metadata()?;
if info.type_ != vfs::FileType::Dir { if info.type_ != vfs::FileType::Dir {
return Err(FsError::NotDir); return Err(FsError::NotDir);
@ -690,10 +695,10 @@ impl vfs::INode for INodeImpl {
} }
} }
} }
fn fs(&self) -> Arc<vfs::FileSystem> { fn fs(&self) -> Arc<dyn vfs::FileSystem> {
self.fs.clone() self.fs.clone()
} }
fn as_any_ref(&self) -> &Any { fn as_any_ref(&self) -> &dyn Any {
self self
} }
} }
@ -725,7 +730,7 @@ pub struct SimpleFileSystem {
/// inode list /// inode list
inodes: RwLock<BTreeMap<INodeId, Weak<INodeImpl>>>, inodes: RwLock<BTreeMap<INodeId, Weak<INodeImpl>>>,
/// device /// device
device: Arc<Device>, device: Arc<dyn Device>,
/// Pointer to self, used by INodes /// Pointer to self, used by INodes
self_ptr: Weak<SimpleFileSystem>, self_ptr: Weak<SimpleFileSystem>,
/// device inode /// device inode
@ -734,7 +739,7 @@ pub struct SimpleFileSystem {
impl SimpleFileSystem { impl SimpleFileSystem {
/// Load SFS from device /// Load SFS from device
pub fn open(device: Arc<Device>) -> vfs::Result<Arc<Self>> { pub fn open(device: Arc<dyn Device>) -> vfs::Result<Arc<Self>> {
let super_block = device.load_struct::<SuperBlock>(BLKN_SUPER)?; let super_block = device.load_struct::<SuperBlock>(BLKN_SUPER)?;
if !super_block.check() { if !super_block.check() {
return Err(FsError::WrongFs); return Err(FsError::WrongFs);
@ -759,7 +764,7 @@ impl SimpleFileSystem {
.wrap()) .wrap())
} }
/// Create a new SFS on blank disk /// Create a new SFS on blank disk
pub fn create(device: Arc<Device>, space: usize) -> vfs::Result<Arc<Self>> { pub fn create(device: Arc<dyn Device>, space: usize) -> vfs::Result<Arc<Self>> {
let blocks = (space + BLKSIZE - 1) / BLKSIZE; let blocks = (space + BLKSIZE - 1) / BLKSIZE;
let freemap_blocks = (space + BLKBITS * BLKSIZE - 1) / BLKBITS / BLKSIZE; let freemap_blocks = (space + BLKBITS * BLKSIZE - 1) / BLKBITS / BLKSIZE;
assert!(blocks >= 16, "space too small"); assert!(blocks >= 16, "space too small");
@ -945,7 +950,7 @@ impl vfs::FileSystem for SimpleFileSystem {
Ok(()) Ok(())
} }
fn root_inode(&self) -> Arc<vfs::INode> { fn root_inode(&self) -> Arc<dyn vfs::INode> {
self.get_inode(BLKN_ROOT) self.get_inode(BLKN_ROOT)
// let root = self.get_inode(BLKN_ROOT); // let root = self.get_inode(BLKN_ROOT);
// root.create("dev", vfs::FileType::Dir, 0).expect("fail to create dev"); // what's mode? // root.create("dev", vfs::FileType::Dir, 0).expect("fail to create dev"); // what's mode?

@ -2,7 +2,7 @@
use crate::vfs; use crate::vfs;
use alloc::str; use alloc::str;
use core::any::Any;
use core::fmt::{Debug, Error, Formatter}; use core::fmt::{Debug, Error, Formatter};
use core::mem::{size_of, size_of_val}; use core::mem::{size_of, size_of_val};
use core::slice; use core::slice;
@ -55,7 +55,7 @@ pub trait DeviceINode : Any + Sync + Send{
} }
*/ */
pub type DeviceINode = vfs::INode; pub type DeviceINode = dyn vfs::INode;
#[repr(C)] #[repr(C)]
pub struct IndirectBlock { pub struct IndirectBlock {

@ -2,14 +2,14 @@ use crate::vfs::{INode, Metadata, Result};
use alloc::{string::String, sync::Arc}; use alloc::{string::String, sync::Arc};
pub struct File { pub struct File {
inode: Arc<INode>, inode: Arc<dyn INode>,
offset: usize, offset: usize,
readable: bool, readable: bool,
writable: bool, writable: bool,
} }
impl File { impl File {
pub fn new(inode: Arc<INode>, readable: bool, writable: bool) -> Self { pub fn new(inode: Arc<dyn INode>, readable: bool, writable: bool) -> Self {
File { File {
inode, inode,
offset: 0, offset: 0,

@ -32,27 +32,33 @@ pub trait INode: Any + Sync + Send {
fn resize(&self, len: usize) -> Result<()>; fn resize(&self, len: usize) -> Result<()>;
/// Create a new INode in the directory /// Create a new INode in the directory
fn create(&self, name: &str, type_: FileType, mode: u32) -> Result<Arc<INode>>{ fn create(&self, name: &str, type_: FileType, mode: u32) -> Result<Arc<dyn INode>> {
self.create2(name, type_, mode, 0) self.create2(name, type_, mode, 0)
} }
/// Create a new INode in the directory, with a data field for usages like device file. /// Create a new INode in the directory, with a data field for usages like device file.
fn create2(&self, name: &str, type_: FileType, mode: u32, data: usize) -> Result<Arc<INode>>{ fn create2(
&self,
name: &str,
type_: FileType,
mode: u32,
_data: usize,
) -> Result<Arc<dyn INode>> {
self.create(name, type_, mode) self.create(name, type_, mode)
} }
/// Create a hard link `name` to `other` /// Create a hard link `name` to `other`
fn link(&self, name: &str, other: &Arc<INode>) -> Result<()>; fn link(&self, name: &str, other: &Arc<dyn INode>) -> Result<()>;
/// Delete a hard link `name` /// Delete a hard link `name`
fn unlink(&self, name: &str) -> Result<()>; fn unlink(&self, name: &str) -> Result<()>;
/// Move INode `self/old_name` to `target/new_name`. /// Move INode `self/old_name` to `target/new_name`.
/// If `target` equals `self`, do rename. /// If `target` equals `self`, do rename.
fn move_(&self, old_name: &str, target: &Arc<INode>, new_name: &str) -> Result<()>; fn move_(&self, old_name: &str, target: &Arc<dyn INode>, new_name: &str) -> Result<()>;
/// Find the INode `name` in the directory /// Find the INode `name` in the directory
fn find(&self, name: &str) -> Result<Arc<INode>>; fn find(&self, name: &str) -> Result<Arc<dyn INode>>;
/// Get the name of directory entry /// Get the name of directory entry
fn get_entry(&self, id: usize) -> Result<String>; fn get_entry(&self, id: usize) -> Result<String>;
@ -61,14 +67,14 @@ pub trait INode: Any + Sync + Send {
fn io_control(&self, cmd: u32, data: usize) -> Result<()>; fn io_control(&self, cmd: u32, data: usize) -> Result<()>;
/// Get the file system of the INode /// Get the file system of the INode
fn fs(&self) -> Arc<FileSystem>; fn fs(&self) -> Arc<dyn FileSystem>;
/// This is used to implement dynamics cast. /// This is used to implement dynamics cast.
/// Simply return self in the implement of the function. /// Simply return self in the implement of the function.
fn as_any_ref(&self) -> &Any; fn as_any_ref(&self) -> &dyn Any;
} }
impl INode { impl dyn INode {
/// Downcast the INode to specific struct /// Downcast the INode to specific struct
pub fn downcast_ref<T: INode>(&self) -> Option<&T> { pub fn downcast_ref<T: INode>(&self) -> Option<&T> {
self.as_any_ref().downcast_ref::<T>() self.as_any_ref().downcast_ref::<T>()
@ -88,12 +94,12 @@ impl INode {
} }
/// Lookup path from current INode, and do not follow symlinks /// Lookup path from current INode, and do not follow symlinks
pub fn lookup(&self, path: &str) -> Result<Arc<INode>> { pub fn lookup(&self, path: &str) -> Result<Arc<dyn INode>> {
self.lookup_follow(path, 0) self.lookup_follow(path, 0)
} }
/// Lookup path from current INode, and follow symlinks at most `follow_times` times /// Lookup path from current INode, and follow symlinks at most `follow_times` times
pub fn lookup_follow(&self, path: &str, mut follow_times: usize) -> Result<Arc<INode>> { pub fn lookup_follow(&self, path: &str, mut follow_times: usize) -> Result<Arc<dyn INode>> {
if self.metadata()?.type_ != FileType::Dir { if self.metadata()?.type_ != FileType::Dir {
return Err(FsError::NotDir); return Err(FsError::NotDir);
} }
@ -263,7 +269,7 @@ pub enum FsError {
DeviceError, DeviceError,
IOCTLError, IOCTLError,
NoDevice, NoDevice,
Again, // E_AGAIN, when no data is available, never happens in fs Again, // E_AGAIN, when no data is available, never happens in fs
SymLoop, //E_LOOP SymLoop, //E_LOOP
} }
@ -285,12 +291,12 @@ impl std::error::Error for FsError {}
pub type Result<T> = result::Result<T, FsError>; pub type Result<T> = result::Result<T, FsError>;
/// Abstract file system /// Abstract file system
pub trait FileSystem: Sync+Send { pub trait FileSystem: Sync + Send {
/// Sync all data to the storage /// Sync all data to the storage
fn sync(&self) -> Result<()>; fn sync(&self) -> Result<()>;
/// Get the root INode of the file system /// Get the root INode of the file system
fn root_inode(&self) -> Arc<INode>; fn root_inode(&self) -> Arc<dyn INode>;
/// Get the file system information /// Get the file system information
fn info(&self) -> FsInfo; fn info(&self) -> FsInfo;

Loading…
Cancel
Save