Skip to main content

hyprstream_vfs/
fuse_adapter.rs

1//! `FileSystem` → `Mount`/`FsMount` **up-adapter** (native only).
2//!
3//! Anything that is already a [`fuse_backend_rs::api::filesystem::FileSystem`]
4//! — RAFS (via `nydus-rafs`), `OverlayFs`, `PassthroughFs` — can be exposed to
5//! the hyprstream VFS as an [`FsMount`] (and therefore a [`Mount`]) by this
6//! wrapper. It is the "up" half of the bidirectional `FileSystem ↔ Mount`
7//! bridge described in the converged FS/VFS design; the "down" half
8//! (`Namespace → FileSystem`) is FS-A and is intentionally **not** built here.
9//!
10//! ## Path model
11//!
12//! `FileSystem` is inode/handle based and resolves one path component at a time
13//! via `lookup`. The VFS, by contrast, hands a backend a *component slice*
14//! rooted at the mount root. The adapter bridges the two by walking from the
15//! filesystem root inode, calling `lookup` per component and `forget`-ing the
16//! intermediates so the wrapped FS's lookup counts stay balanced.
17//!
18//! ## Subject threading
19//!
20//! Every op carries the verified [`Subject`]. There is no host uid/gid backing
21//! a VFS caller, so the FUSE [`Context`] is constructed neutrally (root creds);
22//! the `Subject` is carried alongside for the policy/audit boundary
23//! (#353/#319/#328) and is where FS-A/FS-D will hook per-tenant enforcement.
24//! Mutating ops are fail-closed: any error from the wrapped FS surfaces as a
25//! [`MountError`].
26//!
27//! ## Send + Sync
28//!
29//! Natively this wrapper is *genuinely* `Send + Sync` (its `FileSystem` is, by
30//! the trait bounds we require) — we do **not** use the wasm `unsafe impl Send`
31//! escape hatch. The whole module is `cfg(not(target_arch = "wasm32"))`.
32
33use std::ffi::CString;
34use std::io;
35
36use async_trait::async_trait;
37use fuse_backend_rs::abi::fuse_abi::CreateIn;
38use fuse_backend_rs::api::filesystem::{Context, FileSystem, FsOptions, SetattrValid};
39use parking_lot::Mutex;
40
41use hyprstream_rpc::Subject;
42
43use crate::fsmount::{FsMount, SetAttr};
44use crate::mount::{DirEntry, Fid, Mount, MountError, Stat, ORDWR, OTRUNC, OWRITE};
45
46mod zerocopy;
47use zerocopy::{MemReader, MemWriter};
48
49/// FUSE root inode (`FUSE_ROOT_ID`).
50const ROOT_INODE: u64 = 1;
51
52/// Map a `std::io::Error` (the wrapped FS's error type) to a [`MountError`].
53fn map_io(err: io::Error, ctx: &str) -> MountError {
54    use io::ErrorKind::*;
55    let msg = format!("{ctx}: {err}");
56    match err.raw_os_error() {
57        Some(libc::ENOENT) => MountError::NotFound(msg),
58        Some(libc::EEXIST) => MountError::AlreadyExists(msg),
59        Some(libc::EACCES) | Some(libc::EPERM) => MountError::PermissionDenied(msg),
60        Some(libc::ENOTDIR) => MountError::NotDirectory(msg),
61        Some(libc::EISDIR) => MountError::IsDirectory(msg),
62        Some(libc::EINVAL) => MountError::InvalidArgument(msg),
63        Some(libc::ENOSYS) | Some(libc::ENOTSUP) => MountError::NotSupported(msg),
64        _ => match err.kind() {
65            NotFound => MountError::NotFound(msg),
66            AlreadyExists => MountError::AlreadyExists(msg),
67            PermissionDenied => MountError::PermissionDenied(msg),
68            InvalidInput => MountError::InvalidArgument(msg),
69            Unsupported => MountError::NotSupported(msg),
70            _ => MountError::Io(msg),
71        },
72    }
73}
74
75fn cstr(name: &str) -> Result<CString, MountError> {
76    CString::new(name).map_err(|_| MountError::InvalidArgument(format!("interior NUL in '{name}'")))
77}
78
79/// A neutral FUSE context. VFS callers have no host uid/gid; the [`Subject`] is
80/// the real identity and is threaded separately for policy/audit.
81fn context() -> Context {
82    Context::default()
83}
84
85/// Per-fid state held inside a [`Fid`]: the resolved inode, the open handle (if
86/// the fid has been `open`ed), the open mode, and whether it is a directory.
87struct FuseFid {
88    inode: u64,
89    handle: Option<u64>,
90    mode: u8,
91    is_dir: bool,
92    /// Whether a remove-on-clunk (`ORCLOSE`) was requested. We need the parent
93    /// inode + name to action it, captured at walk time.
94    rclose: Option<(u64, String, bool)>,
95}
96
97/// Up-adapter: exposes a `fuse_backend_rs` [`FileSystem`] as an [`FsMount`].
98///
99/// `F::Inode` and `F::Handle` are required to be `u64` (which `OverlayFs`,
100/// `PassthroughFs` and RAFS all use) so the adapter can store them in a generic
101/// [`Fid`] without per-FS associated-type juggling.
102pub struct FuseFileSystemMount<F>
103where
104    F: FileSystem<Inode = u64, Handle = u64> + Send + Sync,
105{
106    fs: F,
107    /// Guards lookup-count bookkeeping. The wrapped `FileSystem` ops are `&self`
108    /// and internally synchronised, but per-op walk/forget sequences are
109    /// composite; the mutex keeps a mount's lookup accounting linearizable.
110    lookup_guard: Mutex<()>,
111}
112
113impl<F> FuseFileSystemMount<F>
114where
115    F: FileSystem<Inode = u64, Handle = u64> + Send + Sync,
116{
117    /// Wrap `fs`, running its `init` so option negotiation (writeback, etc.)
118    /// happens once. Use this for filesystems that are ready to serve (e.g. a
119    /// `PassthroughFs` whose `import()` has been called, or an imported
120    /// `OverlayFs`).
121    pub fn new(fs: F) -> Result<Self, MountError> {
122        fs.init(FsOptions::empty())
123            .map_err(|e| map_io(e, "FileSystem::init"))?;
124        Ok(Self {
125            fs,
126            lookup_guard: Mutex::new(()),
127        })
128    }
129
130    /// Borrow the wrapped filesystem (e.g. to call backend-specific setup).
131    pub fn inner(&self) -> &F {
132        &self.fs
133    }
134
135    /// Resolve the parent directory inode plus the final component name.
136    ///
137    /// Empty `path` is the root itself and has no name — callers that need a
138    /// final component (`create`, `unlink`, …) reject it.
139    fn resolve_parent(&self, path: &[&str], ctx: &Context) -> Result<(u64, String), MountError> {
140        let (last, parents) = path
141            .split_last()
142            .ok_or_else(|| MountError::InvalidArgument("operation requires a path".into()))?;
143        let parent = self.resolve(parents, ctx)?;
144        Ok((parent, (*last).to_owned()))
145    }
146
147    /// Walk `components` from the root inode, returning the resolved inode.
148    ///
149    /// Each `lookup` increments the wrapped FS's lookup count; we `forget` every
150    /// intermediate so only the *returned* inode is left referenced. Callers that
151    /// take ownership of the returned inode for a longer-lived fid must `forget`
152    /// it on clunk; transient resolutions should pair with [`Self::forget`].
153    fn resolve(&self, components: &[&str], ctx: &Context) -> Result<u64, MountError> {
154        let mut inode = ROOT_INODE;
155        for (i, comp) in components.iter().enumerate() {
156            if comp.is_empty() || *comp == "." {
157                continue;
158            }
159            let name = cstr(comp)?;
160            let entry = self
161                .fs
162                .lookup(ctx, inode, &name)
163                .map_err(|e| map_io(e, "lookup"))?;
164            if entry.inode == 0 {
165                // Negative entry — release any intermediates we hold.
166                if inode != ROOT_INODE {
167                    self.fs.forget(ctx, inode, 1);
168                }
169                return Err(MountError::NotFound(components[..=i].join("/")));
170            }
171            // Drop the parent's reference now that we've descended.
172            if inode != ROOT_INODE {
173                self.fs.forget(ctx, inode, 1);
174            }
175            inode = entry.inode;
176        }
177        Ok(inode)
178    }
179
180    /// Drop one lookup reference on `inode` (no-op for the root).
181    fn forget(&self, inode: u64, ctx: &Context) {
182        if inode != ROOT_INODE {
183            self.fs.forget(ctx, inode, 1);
184        }
185    }
186
187    /// Convert a FUSE [`Entry`] / `stat64` into the VFS [`Stat`] shape.
188    fn entry_stat(name: &str, attr: &libc::stat64) -> Stat {
189        let is_dir = attr.st_mode & libc::S_IFMT == libc::S_IFDIR;
190        Stat {
191            qtype: if is_dir { 0x80 } else { 0 },
192            version: 0,
193            path: attr.st_ino,
194            size: attr.st_size as u64,
195            name: name.to_owned(),
196            mtime: attr.st_mtime as u64,
197        }
198    }
199
200    /// `getattr` for an inode.
201    fn getattr(&self, inode: u64, ctx: &Context) -> Result<libc::stat64, MountError> {
202        self.fs
203            .getattr(ctx, inode, None)
204            .map(|(st, _)| st)
205            .map_err(|e| map_io(e, "getattr"))
206    }
207}
208
209#[async_trait]
210impl<F> Mount for FuseFileSystemMount<F>
211where
212    F: FileSystem<Inode = u64, Handle = u64> + Send + Sync,
213{
214    async fn walk(&self, components: &[&str], _caller: &Subject) -> Result<Fid, MountError> {
215        let ctx = context();
216        let _g = self.lookup_guard.lock();
217
218        // Capture the parent + name so ORCLOSE can action a remove on clunk.
219        let rclose_target = match components.split_last() {
220            Some((last, parents)) => {
221                let parent = self.resolve(parents, &ctx)?;
222                let name = cstr(last)?;
223                let entry = self
224                    .fs
225                    .lookup(&ctx, parent, &name)
226                    .map_err(|e| map_io(e, "walk lookup"))?;
227                if entry.inode == 0 {
228                    self.forget(parent, &ctx);
229                    return Err(MountError::NotFound(components.join("/")));
230                }
231                let is_dir = entry.attr.st_mode & libc::S_IFMT == libc::S_IFDIR;
232                // Hold the parent ref for the lifetime of the fid (ORCLOSE needs
233                // it); the resolved inode ref is the fid's.
234                Some((parent, last.to_string(), is_dir, entry.inode))
235            }
236            None => None, // root
237        };
238
239        match rclose_target {
240            Some((parent, name, is_dir, inode)) => Ok(Fid::new(FuseFid {
241                inode,
242                handle: None,
243                mode: 0,
244                is_dir,
245                rclose: Some((parent, name, is_dir)),
246            })),
247            None => {
248                let attr = self.getattr(ROOT_INODE, &ctx)?;
249                let is_dir = attr.st_mode & libc::S_IFMT == libc::S_IFDIR;
250                Ok(Fid::new(FuseFid {
251                    inode: ROOT_INODE,
252                    handle: None,
253                    mode: 0,
254                    is_dir,
255                    rclose: None,
256                }))
257            }
258        }
259    }
260
261    async fn open(&self, fid: &mut Fid, mode: u8, _caller: &Subject) -> Result<(), MountError> {
262        let ctx = context();
263        let inner = fid
264            .downcast_mut::<FuseFid>()
265            .ok_or_else(|| MountError::InvalidArgument("bad fid".into()))?;
266        inner.mode = mode;
267
268        // Truncate-on-open is a setattr(size=0) on the writable layer.
269        if mode & OTRUNC != 0 && !inner.is_dir {
270            let mut attr: libc::stat64 = unsafe { std::mem::zeroed() };
271            attr.st_size = 0;
272            self.fs
273                .setattr(&ctx, inner.inode, attr, None, SetattrValid::SIZE)
274                .map_err(|e| map_io(e, "open OTRUNC"))?;
275        }
276
277        if inner.is_dir {
278            let (handle, _) = self
279                .fs
280                .opendir(&ctx, inner.inode, libc::O_RDONLY as u32)
281                .map_err(|e| map_io(e, "opendir"))?;
282            inner.handle = handle;
283        } else {
284            let flags = match mode & 0x03 {
285                OWRITE => libc::O_WRONLY,
286                ORDWR => libc::O_RDWR,
287                _ => libc::O_RDONLY,
288            } as u32;
289            let (handle, _, _) = self
290                .fs
291                .open(&ctx, inner.inode, flags, 0)
292                .map_err(|e| map_io(e, "open"))?;
293            inner.handle = handle;
294        }
295        Ok(())
296    }
297
298    async fn read(
299        &self,
300        fid: &Fid,
301        offset: u64,
302        count: u32,
303        _caller: &Subject,
304    ) -> Result<Vec<u8>, MountError> {
305        let ctx = context();
306        let inner = fid
307            .downcast_ref::<FuseFid>()
308            .ok_or_else(|| MountError::InvalidArgument("bad fid".into()))?;
309        let handle = inner.handle.unwrap_or(0);
310        let mut writer = MemWriter::with_capacity(count as usize);
311        self.fs
312            .read(
313                &ctx,
314                inner.inode,
315                handle,
316                &mut writer,
317                count,
318                offset,
319                None,
320                0,
321            )
322            .map_err(|e| map_io(e, "read"))?;
323        Ok(writer.into_inner())
324    }
325
326    async fn write(
327        &self,
328        fid: &Fid,
329        offset: u64,
330        data: &[u8],
331        _caller: &Subject,
332    ) -> Result<u32, MountError> {
333        let ctx = context();
334        let inner = fid
335            .downcast_ref::<FuseFid>()
336            .ok_or_else(|| MountError::InvalidArgument("bad fid".into()))?;
337        let handle = inner.handle.unwrap_or(0);
338        let mut reader = MemReader::new(data);
339        let n = self
340            .fs
341            .write(
342                &ctx,
343                inner.inode,
344                handle,
345                &mut reader,
346                data.len() as u32,
347                offset,
348                None,
349                false,
350                0,
351                0,
352            )
353            .map_err(|e| map_io(e, "write"))?;
354        Ok(n as u32)
355    }
356
357    async fn readdir(&self, fid: &Fid, _caller: &Subject) -> Result<Vec<DirEntry>, MountError> {
358        let ctx = context();
359        let inner = fid
360            .downcast_ref::<FuseFid>()
361            .ok_or_else(|| MountError::InvalidArgument("bad fid".into()))?;
362        let handle = inner.handle.unwrap_or(0);
363
364        let mut names: Vec<(String, bool)> = Vec::new();
365        // Page through the directory until a pass yields nothing new.
366        let mut offset = 0u64;
367        loop {
368            let before = names.len();
369            self.fs
370                .readdir(&ctx, inner.inode, handle, 1 << 16, offset, &mut |e| {
371                    offset = e.offset;
372                    let name = String::from_utf8_lossy(e.name).into_owned();
373                    if name != "." && name != ".." {
374                        let is_dir = e.type_ == libc::DT_DIR as u32;
375                        names.push((name, is_dir));
376                    }
377                    Ok(1)
378                })
379                .map_err(|e| map_io(e, "readdir"))?;
380            if names.len() == before {
381                break;
382            }
383        }
384
385        // Resolve sizes/attrs per entry via lookup (best-effort; skip on error).
386        let mut entries = Vec::with_capacity(names.len());
387        for (name, is_dir) in names {
388            let c = match cstr(&name) {
389                Ok(c) => c,
390                Err(_) => continue,
391            };
392            let (size, stat) = match self.fs.lookup(&ctx, inner.inode, &c) {
393                Ok(entry) if entry.inode != 0 => {
394                    let st = Self::entry_stat(&name, &entry.attr);
395                    let size = entry.attr.st_size as u64;
396                    self.forget(entry.inode, &ctx);
397                    (size, Some(st))
398                }
399                _ => (0, None),
400            };
401            entries.push(DirEntry {
402                name,
403                is_dir,
404                size,
405                stat,
406            });
407        }
408        Ok(entries)
409    }
410
411    async fn stat(&self, fid: &Fid, _caller: &Subject) -> Result<Stat, MountError> {
412        let ctx = context();
413        let inner = fid
414            .downcast_ref::<FuseFid>()
415            .ok_or_else(|| MountError::InvalidArgument("bad fid".into()))?;
416        let attr = self.getattr(inner.inode, &ctx)?;
417        Ok(Self::entry_stat("", &attr))
418    }
419
420    fn as_fsmount(&self) -> Option<&dyn FsMount> {
421        Some(self)
422    }
423
424    async fn clunk(&self, fid: Fid, _caller: &Subject) {
425        let ctx = context();
426        let Some(inner) = fid.downcast_ref::<FuseFid>() else {
427            return;
428        };
429        // Release the open handle, if any.
430        if let Some(handle) = inner.handle {
431            if inner.is_dir {
432                let _ = self
433                    .fs
434                    .releasedir(&ctx, inner.inode, libc::O_RDONLY as u32, handle);
435            } else {
436                let _ = self
437                    .fs
438                    .release(&ctx, inner.inode, 0, handle, true, false, None);
439            }
440        }
441        // Action ORCLOSE (remove-on-clunk).
442        if inner.mode & crate::mount::ORCLOSE != 0 {
443            if let Some((parent, name, is_dir)) = &inner.rclose {
444                if let Ok(c) = cstr(name) {
445                    let _ = if *is_dir {
446                        self.fs.rmdir(&ctx, *parent, &c)
447                    } else {
448                        self.fs.unlink(&ctx, *parent, &c)
449                    };
450                }
451            }
452        }
453        // Balance lookup counts: the fid's own inode, and the held parent (if any).
454        self.forget(inner.inode, &ctx);
455        if let Some((parent, _, _)) = &inner.rclose {
456            self.forget(*parent, &ctx);
457        }
458    }
459}
460
461#[async_trait]
462impl<F> FsMount for FuseFileSystemMount<F>
463where
464    F: FileSystem<Inode = u64, Handle = u64> + Send + Sync,
465{
466    async fn create(&self, path: &[&str], mode: u32, caller: &Subject) -> Result<(), MountError> {
467        let ctx = context();
468        let _g = self.lookup_guard.lock();
469        let (parent, name) = self.resolve_parent(path, &ctx)?;
470        let cname = cstr(&name)?;
471        let args = CreateIn {
472            flags: (libc::O_CREAT | libc::O_EXCL | libc::O_WRONLY) as u32,
473            mode,
474            umask: 0,
475            fuse_flags: 0,
476        };
477        let res = self.fs.create(&ctx, parent, &cname, args);
478        self.forget(parent, &ctx);
479        let (entry, handle, _, _) = res.map_err(|e| map_io(e, "create"))?;
480        // We created and opened the file; close the handle immediately — the VFS
481        // create op only guarantees existence, callers re-open to write.
482        if let Some(h) = handle {
483            let _ = self
484                .fs
485                .release(&ctx, entry.inode, args.flags, h, true, false, None);
486        }
487        self.forget(entry.inode, &ctx);
488        let _ = caller; // carried for policy boundary; no host cred mapping yet
489        Ok(())
490    }
491
492    async fn unlink(&self, path: &[&str], _caller: &Subject) -> Result<(), MountError> {
493        let ctx = context();
494        let _g = self.lookup_guard.lock();
495        let (parent, name) = self.resolve_parent(path, &ctx)?;
496        let cname = cstr(&name)?;
497        let res = self.fs.unlink(&ctx, parent, &cname);
498        self.forget(parent, &ctx);
499        res.map_err(|e| map_io(e, "unlink"))
500    }
501
502    async fn mkdir(&self, path: &[&str], mode: u32, _caller: &Subject) -> Result<(), MountError> {
503        let ctx = context();
504        let _g = self.lookup_guard.lock();
505        let (parent, name) = self.resolve_parent(path, &ctx)?;
506        let cname = cstr(&name)?;
507        let res = self.fs.mkdir(&ctx, parent, &cname, mode, 0);
508        self.forget(parent, &ctx);
509        let entry = res.map_err(|e| map_io(e, "mkdir"))?;
510        self.forget(entry.inode, &ctx);
511        Ok(())
512    }
513
514    async fn rmdir(&self, path: &[&str], _caller: &Subject) -> Result<(), MountError> {
515        let ctx = context();
516        let _g = self.lookup_guard.lock();
517        let (parent, name) = self.resolve_parent(path, &ctx)?;
518        let cname = cstr(&name)?;
519        let res = self.fs.rmdir(&ctx, parent, &cname);
520        self.forget(parent, &ctx);
521        res.map_err(|e| map_io(e, "rmdir"))
522    }
523
524    async fn rename(
525        &self,
526        from: &[&str],
527        to: &[&str],
528        _caller: &Subject,
529    ) -> Result<(), MountError> {
530        let ctx = context();
531        let _g = self.lookup_guard.lock();
532        let (old_dir, old_name) = self.resolve_parent(from, &ctx)?;
533        let (new_dir, new_name) = match self.resolve_parent(to, &ctx) {
534            Ok(v) => v,
535            Err(e) => {
536                self.forget(old_dir, &ctx);
537                return Err(e);
538            }
539        };
540        let old_c = cstr(&old_name)?;
541        let new_c = cstr(&new_name)?;
542        let res = self.fs.rename(&ctx, old_dir, &old_c, new_dir, &new_c, 0);
543        self.forget(old_dir, &ctx);
544        self.forget(new_dir, &ctx);
545        res.map_err(|e| map_io(e, "rename"))
546    }
547
548    async fn setattr(
549        &self,
550        path: &[&str],
551        attr: &SetAttr,
552        _caller: &Subject,
553    ) -> Result<(), MountError> {
554        let ctx = context();
555        if attr.is_empty() {
556            return Ok(());
557        }
558        let _g = self.lookup_guard.lock();
559        let inode = self.resolve(path, &ctx)?;
560        let mut st: libc::stat64 = unsafe { std::mem::zeroed() };
561        let mut valid = SetattrValid::empty();
562        if let Some(mode) = attr.mode {
563            st.st_mode = mode;
564            valid |= SetattrValid::MODE;
565        }
566        if let Some(uid) = attr.uid {
567            st.st_uid = uid;
568            valid |= SetattrValid::UID;
569        }
570        if let Some(gid) = attr.gid {
571            st.st_gid = gid;
572            valid |= SetattrValid::GID;
573        }
574        if let Some(size) = attr.size {
575            st.st_size = size as i64;
576            valid |= SetattrValid::SIZE;
577        }
578        if let Some(atime) = attr.atime {
579            st.st_atime = atime as i64;
580            valid |= SetattrValid::ATIME;
581        }
582        if let Some(mtime) = attr.mtime {
583            st.st_mtime = mtime as i64;
584            valid |= SetattrValid::MTIME;
585        }
586        let res = self.fs.setattr(&ctx, inode, st, None, valid);
587        self.forget(inode, &ctx);
588        res.map(|_| ()).map_err(|e| map_io(e, "setattr"))
589    }
590
591    async fn symlink(
592        &self,
593        path: &[&str],
594        target: &str,
595        _caller: &Subject,
596    ) -> Result<(), MountError> {
597        let ctx = context();
598        let _g = self.lookup_guard.lock();
599        let (parent, name) = self.resolve_parent(path, &ctx)?;
600        let cname = cstr(&name)?;
601        let ctarget = cstr(target)?;
602        let res = self.fs.symlink(&ctx, &ctarget, parent, &cname);
603        self.forget(parent, &ctx);
604        let entry = res.map_err(|e| map_io(e, "symlink"))?;
605        self.forget(entry.inode, &ctx);
606        Ok(())
607    }
608
609    async fn readlink(&self, path: &[&str], _caller: &Subject) -> Result<String, MountError> {
610        let ctx = context();
611        let _g = self.lookup_guard.lock();
612        let inode = self.resolve(path, &ctx)?;
613        let res = self.fs.readlink(&ctx, inode);
614        self.forget(inode, &ctx);
615        let bytes = res.map_err(|e| map_io(e, "readlink"))?;
616        Ok(String::from_utf8_lossy(&bytes).into_owned())
617    }
618
619    async fn link(
620        &self,
621        existing: &[&str],
622        new_path: &[&str],
623        _caller: &Subject,
624    ) -> Result<(), MountError> {
625        let ctx = context();
626        let _g = self.lookup_guard.lock();
627        let inode = self.resolve(existing, &ctx)?;
628        let (new_parent, new_name) = match self.resolve_parent(new_path, &ctx) {
629            Ok(v) => v,
630            Err(e) => {
631                self.forget(inode, &ctx);
632                return Err(e);
633            }
634        };
635        let cname = cstr(&new_name)?;
636        let res = self.fs.link(&ctx, inode, new_parent, &cname);
637        self.forget(inode, &ctx);
638        self.forget(new_parent, &ctx);
639        let entry = res.map_err(|e| map_io(e, "link"))?;
640        self.forget(entry.inode, &ctx);
641        Ok(())
642    }
643
644    async fn stat_path(&self, path: &[&str], _caller: &Subject) -> Result<Stat, MountError> {
645        let ctx = context();
646        let _g = self.lookup_guard.lock();
647        let inode = self.resolve(path, &ctx)?;
648        let attr = self.getattr(inode, &ctx);
649        self.forget(inode, &ctx);
650        let name = path.last().copied().unwrap_or("");
651        Ok(Self::entry_stat(name, &attr?))
652    }
653}