From 0eba40886d36311b28d42ff2a27a0f4292e2ad9f Mon Sep 17 00:00:00 2001 From: WangRunji Date: Tue, 12 Mar 2019 11:01:14 +0800 Subject: [PATCH] convert SFS device from Box -> Arc --- rcore-fs-fuse/src/main.rs | 4 ++-- rcore-fs-sfs/src/lib.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rcore-fs-fuse/src/main.rs b/rcore-fs-fuse/src/main.rs index 019139e..77f9080 100644 --- a/rcore-fs-fuse/src/main.rs +++ b/rcore-fs-fuse/src/main.rs @@ -64,8 +64,8 @@ fn main() { let device = Mutex::new(file); const MAX_SPACE: usize = 0x1000 * 0x1000 * 8; // 128MB (4K bitmap) match create { - true => sfs::SimpleFileSystem::create(Box::new(device), MAX_SPACE), - false => sfs::SimpleFileSystem::open(Box::new(device)) + true => sfs::SimpleFileSystem::create(Arc::new(device), MAX_SPACE), + false => sfs::SimpleFileSystem::open(Arc::new(device)) .expect("failed to open sfs"), } } diff --git a/rcore-fs-sfs/src/lib.rs b/rcore-fs-sfs/src/lib.rs index 822c811..9cc1aac 100644 --- a/rcore-fs-sfs/src/lib.rs +++ b/rcore-fs-sfs/src/lib.rs @@ -216,7 +216,7 @@ impl INodeImpl { // Note: the _\w*_at method always return begin>size?0:begin(&self, begin: usize, end: usize, mut f: F) -> vfs::Result - where F: FnMut(&Box, &BlockRange, usize) -> vfs::Result<()> + where F: FnMut(&Arc, &BlockRange, usize) -> vfs::Result<()> { let size = self._size(); let iter = BlockIter { @@ -553,14 +553,14 @@ pub struct SimpleFileSystem { /// inode list inodes: RwLock>>, /// device - device: Box, + device: Arc, /// Pointer to self, used by INodes self_ptr: Weak, } impl SimpleFileSystem { /// Load SFS from device - pub fn open(device: Box) -> vfs::Result> { + pub fn open(device: Arc) -> vfs::Result> { let super_block = device.load_struct::(BLKN_SUPER).unwrap(); if !super_block.check() { return Err(FsError::WrongFs); @@ -576,7 +576,7 @@ impl SimpleFileSystem { }.wrap()) } /// Create a new SFS on blank disk - pub fn create(device: Box, space: usize) -> Arc { + pub fn create(device: Arc, space: usize) -> Arc { let blocks = (space / BLKSIZE).min(BLKBITS); assert!(blocks >= 16, "space too small");