fuse2: getattr: prefer fh lookup if possible

This commit is contained in:
Thomas Waldmann 2025-11-25 20:27:49 +01:00
parent 0aa7c16749
commit 71416d76f4
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -540,9 +540,15 @@ class borgfs(mfuse.Operations, FuseBackend):
def getattr(self, path, fh=None):
debug_log(f"getattr(path={path!r}, fh={fh})")
node = self._find_node(path)
if node is None:
raise mfuse.FuseOSError(errno.ENOENT)
if fh is not None:
# use file handle if available to avoid path lookup
node = self._get_node_from_handle(fh)
if node is None:
raise mfuse.FuseOSError(errno.EBADF)
else:
node = self._find_node(path)
if node is None:
raise mfuse.FuseOSError(errno.ENOENT)
st = self._make_stat_dict(node)
debug_log(f"getattr -> {st}")
return st