From e640f7813468211a0e84416683bbf2f171936a6c Mon Sep 17 00:00:00 2001 From: Ben Pig Chu Date: Sat, 27 Oct 2018 01:53:15 +0800 Subject: [PATCH] untested single layer lookup named find --- src/sfs.rs | 11 +++++++++++ src/vfs.rs | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/sfs.rs b/src/sfs.rs index abb201e..e505f28 100644 --- a/src/sfs.rs +++ b/src/sfs.rs @@ -396,6 +396,17 @@ impl vfs::INode for INode { _ => unimplemented!(), } } + fn find(&self, name: &str) -> vfs::Result> { + let fs = self.fs.upgrade().unwrap(); + let info = self.info().unwrap(); + assert_eq!(info.type_, vfs::FileType::Dir); + let inode_id = self.get_file_inode_id(name); + if inode_id.is_none() { + return Err(()); + } + let inode = fs.get_inode(inode_id.unwrap()); + Ok(inode) + } fn get_entry(&self,id: usize) -> vfs::Result { assert_eq!(self.disk_inode.type_, FileType::Dir); assert!(id Result<()>; fn lookup(&self, path: &str) -> Result; + /// lookup with only one layer + fn find(&self, name: &str) -> Result; fn list(&self) -> Result>; /// like list()[id] /// only get one item in list, often faster than list