diff --git a/example/src/passthrough.rs b/example/src/passthrough.rs index 1b0fa3b..5f7edde 100644 --- a/example/src/passthrough.rs +++ b/example/src/passthrough.rs @@ -127,6 +127,14 @@ impl FilesystemMT for PassthroughFS { debug!("destroy"); } + fn lookup(&self, _req: RequestInfo, path: &Path) { + debug!("lookup: {:?}", path); + } + + fn forget(&self, _req: RequestInfo, path: &Path) { + debug!("forget: {:?}", path); + } + fn getattr(&self, _req: RequestInfo, path: &Path, fh: Option) -> ResultEntry { debug!("getattr: {:?}", path); diff --git a/src/fusemt.rs b/src/fusemt.rs index e955bab..038ecea 100644 --- a/src/fusemt.rs +++ b/src/fusemt.rs @@ -110,6 +110,7 @@ impl fuse::Filesystem for FuseMT { let parent_path = get_path!(self, parent, reply); debug!("lookup: {:?}, {:?}", parent_path, name); let path = Arc::new((*parent_path).clone().join(name)); + self.target.lookup(req.info(), &path); match self.target.getattr(req.info(), &path, None) { Ok((ttl, attr)) => { let (ino, generation) = self.inodes.add_or_get(path.clone()); @@ -120,10 +121,11 @@ impl fuse::Filesystem for FuseMT { } } - fn forget(&mut self, _req: &fuse::Request, ino: u64, nlookup: u64) { + fn forget(&mut self, req: &fuse::Request, ino: u64, nlookup: u64) { let path = self.inodes.get_path(ino).unwrap_or_else(|| { Arc::new(PathBuf::from("[unknown]")) }); + self.target.forget(req.info(), &path); let lookups = self.inodes.forget(ino, nlookup); debug!("forget: inode {} ({:?}) now at {} lookups", ino, path, lookups); } diff --git a/src/types.rs b/src/types.rs index 4e30924..6535a77 100644 --- a/src/types.rs +++ b/src/types.rs @@ -127,6 +127,18 @@ pub trait FilesystemMT { // Nothing. } + /// Called when a path is looked up for the first time. This call will be immediately followed + /// by a call to `getattr` with the same path. + fn lookup(&self, _req: RequestInfo, _path: &Path) { + // Nothing. + } + + /// Called when the kernel is removing an inode from its internal caches. Filesystems can use + /// this to clean up their own caches. + fn forget(&self, _req: RequestInfo, _path: &Path) { + // Nothing. + } + /// Get the attributes of a filesystem entry. /// /// * `fh`: a file handle if this is called on an open file.