From ab5ae3a447a8a98f8bdbfced6e7852b17180f617 Mon Sep 17 00:00:00 2001 From: Tianyu Gao Date: Sun, 12 May 2019 07:49:09 +0000 Subject: [PATCH] fix some conflict, pass building --- rcore-fs-sfs/src/lib.rs | 30 ++++++++++++++---------------- rcore-fs/Cargo.toml | 5 +---- rcore-fs/src/vfs.rs | 2 +- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/rcore-fs-sfs/src/lib.rs b/rcore-fs-sfs/src/lib.rs index f5ffb76..06be195 100644 --- a/rcore-fs-sfs/src/lib.rs +++ b/rcore-fs-sfs/src/lib.rs @@ -11,8 +11,8 @@ use alloc::{ string::String, sync::{Arc, Weak}, vec, - boxed::Box vec::Vec, + boxed::Box }; use core::any::Any; use core::fmt::{Debug, Error, Formatter}; @@ -392,7 +392,8 @@ impl INodeImpl { id: child.id as u32, name: Str256::from(name), }; - let old_size = self._size(); + let mut disk_inode = self.disk_inode.write(); + let old_size = disk_inode.size as usize; self._resize(old_size + BLKSIZE)?; self._write_at(old_size, entry.as_buf()).unwrap(); child.nlinks_inc(); @@ -457,7 +458,6 @@ impl vfs::INode for INodeImpl { FileType::BlockDevice => 0, _ => panic!("Unknown file type"), }, - size: disk_inode.size as usize, mode: 0o777, type_: vfs::FileType::from(disk_inode.type_.clone()), blocks: disk_inode.blocks as usize, @@ -672,29 +672,27 @@ impl vfs::INode for INodeImpl { Ok(String::from(entry.name.as_ref())) } fn io_control(&self, _cmd: u32, _data: usize) -> vfs::Result<()> { - Err(FsError::NotSupported) - } - fn fs(&self) -> Arc { - self.fs.clone() - } - fn as_any_ref(&self) -> &Any { - self - } - - fn ioctl(&self, request: u32, data: *mut u8) -> Result<(), vfs::IOCTLError> { if self.metadata().unwrap().type_ != vfs::FileType::CharDevice { - return Err(vfs::IOCTLError::NotCharDevice); + return Err(FsError::IOCTLError); } let device_inodes = self.fs.device_inodes.read(); let device_inode = device_inodes.get(&self.device_inode_id); match device_inode { - Some(x) => { x.ioctl(request, data) } + Some(x) => { x.io_control(_cmd, _data) } None => { warn!("cannot find corresponding device inode in call_inoctl"); - Err(vfs::IOCTLError::NotCharDevice) + Err(FsError::IOCTLError) } } + + } + fn fs(&self) -> Arc { + self.fs.clone() } + fn as_any_ref(&self) -> &Any { + self + } + } impl Drop for INodeImpl { diff --git a/rcore-fs/Cargo.toml b/rcore-fs/Cargo.toml index 8e682f2..562137a 100644 --- a/rcore-fs/Cargo.toml +++ b/rcore-fs/Cargo.toml @@ -10,8 +10,5 @@ spin = "0.5" [dev-dependencies] tempfile = "3" -[dependencies] -spin = "0.4" - [features] -std = [] \ No newline at end of file +std = [] diff --git a/rcore-fs/src/vfs.rs b/rcore-fs/src/vfs.rs index fbf739b..96b593f 100644 --- a/rcore-fs/src/vfs.rs +++ b/rcore-fs/src/vfs.rs @@ -59,7 +59,6 @@ pub trait INode: Any + Sync + Send { /// This is used to implement dynamics cast. /// Simply return self in the implement of the function. fn as_any_ref(&self) -> &Any; - fn ioctl(&self, request: u32, data: *mut u8) -> result::Result<(), IOCTLError>; } impl INode { @@ -253,6 +252,7 @@ pub enum FsError { DirNotEmpty, //E_NOTEMPTY WrongFs, //E_INVAL, when we find the content on disk is wrong when opening the device DeviceError, + IOCTLError, NoDevice }