From 334f73df086710003b74ef0bc6ef214933118510 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 6 Dec 2025 02:00:15 +0100 Subject: [PATCH] use hlfuse similar to llfuse, move import --- src/borg/fuse_impl.py | 5 ++++- src/borg/hlfuse.py | 33 ++++++++++++++++----------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/borg/fuse_impl.py b/src/borg/fuse_impl.py index 7d529d7a8..aa2343983 100644 --- a/src/borg/fuse_impl.py +++ b/src/borg/fuse_impl.py @@ -20,6 +20,7 @@ for FUSE_IMPL in BORG_FUSE_IMPL.split(","): has_pyfuse3 = True has_mfusepy = False has_any_fuse = True + hlfuse = None # noqa break elif FUSE_IMPL == "llfuse": try: @@ -31,10 +32,11 @@ for FUSE_IMPL in BORG_FUSE_IMPL.split(","): has_pyfuse3 = False has_mfusepy = False has_any_fuse = True + hlfuse = None # noqa break elif FUSE_IMPL == "mfusepy": try: - from .hlfuse import mfuse # noqa + import mfusepy as hlfuse except ImportError: pass else: @@ -50,6 +52,7 @@ for FUSE_IMPL in BORG_FUSE_IMPL.split(","): raise RuntimeError("Unknown FUSE implementation in BORG_FUSE_IMPL: '%s'." % BORG_FUSE_IMPL) else: llfuse = None # noqa + hlfuse = None # noqa has_llfuse = False has_pyfuse3 = False has_mfusepy = False diff --git a/src/borg/hlfuse.py b/src/borg/hlfuse.py index da3fafb90..d27fc3602 100644 --- a/src/borg/hlfuse.py +++ b/src/borg/hlfuse.py @@ -8,8 +8,7 @@ from collections import Counter from .constants import ROBJ_FILE_STREAM, zeros, ROBJ_DONTCARE - -import mfusepy as mfuse +from .fuse_impl import hlfuse from .logger import create_logger @@ -436,13 +435,13 @@ class FuseBackend: return st -class borgfs(mfuse.Operations, FuseBackend): +class borgfs(hlfuse.Operations, FuseBackend): """Export archive as a FUSE filesystem""" use_ns = True def __init__(self, manifest, args, repository): - mfuse.Operations.__init__(self) + hlfuse.Operations.__init__(self) FuseBackend.__init__(self, manifest, args, repository) data_cache_capacity = int(os.environ.get("BORG_MOUNT_DATA_CACHE_ENTRIES", os.cpu_count() or 1)) logger.debug("mount data cache capacity: %d chunks", data_cache_capacity) @@ -511,7 +510,7 @@ class borgfs(mfuse.Operations, FuseBackend): ) self._create_filesystem() - # mfuse.FUSE will block if foreground=True, otherwise it returns immediately + # hlfuse.FUSE will block if foreground=True, otherwise it returns immediately if not foreground: # Background mode: daemonize first, then start FUSE (blocking) if isinstance(self.repository, RemoteRepository): @@ -523,7 +522,7 @@ class borgfs(mfuse.Operations, FuseBackend): # Run the FUSE main loop in foreground (we might be daemonized already or not) with signal_handler("SIGUSR1", self.sig_info_handler), signal_handler("SIGINFO", self.sig_info_handler): - mfuse.FUSE(self, mountpoint, options, foreground=True, use_ino=True) + hlfuse.FUSE(self, mountpoint, options, foreground=True, use_ino=True) def statfs(self, path): debug_log(f"statfs(path={path!r})") @@ -546,11 +545,11 @@ class borgfs(mfuse.Operations, FuseBackend): # 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) + raise hlfuse.FuseOSError(errno.EBADF) else: node = self._find_node(path) if node is None: - raise mfuse.FuseOSError(errno.ENOENT) + raise hlfuse.FuseOSError(errno.ENOENT) st = self._make_stat_dict(node) debug_log(f"getattr -> {st}") return st @@ -559,7 +558,7 @@ class borgfs(mfuse.Operations, FuseBackend): debug_log(f"listxattr(path={path!r})") node = self._find_node(path) if node is None: - raise mfuse.FuseOSError(errno.ENOENT) + raise hlfuse.FuseOSError(errno.ENOENT) item = self.get_inode(node.ino) result = [k.decode("utf-8", "surrogateescape") for k in item.get("xattrs", {}).keys()] debug_log(f"listxattr -> {result}") @@ -569,7 +568,7 @@ class borgfs(mfuse.Operations, FuseBackend): debug_log(f"getxattr(path={path!r}, name={name!r}, position={position})") node = self._find_node(path) if node is None: - raise mfuse.FuseOSError(errno.ENOENT) + raise hlfuse.FuseOSError(errno.ENOENT) item = self.get_inode(node.ino) try: if isinstance(name, str): @@ -579,13 +578,13 @@ class borgfs(mfuse.Operations, FuseBackend): return result except KeyError: debug_log("getxattr -> ENODATA") - raise mfuse.FuseOSError(errno.ENODATA) from None + raise hlfuse.FuseOSError(errno.ENODATA) from None def open(self, path, fi): debug_log(f"open(path={path!r}, fi={fi})") node = self._find_node(path) if node is None: - raise mfuse.FuseOSError(errno.ENOENT) + raise hlfuse.FuseOSError(errno.ENOENT) fh = self._get_handle(node) fi.fh = fh debug_log(f"open -> fh={fh}") @@ -599,14 +598,14 @@ class borgfs(mfuse.Operations, FuseBackend): def create(self, path, mode, fi=None): debug_log(f"create(path={path!r}, mode={mode}, fi={fi}) -> EROFS") - raise mfuse.FuseOSError(errno.EROFS) + raise hlfuse.FuseOSError(errno.EROFS) def read(self, path, size, offset, fi): fh = fi.fh debug_log(f"read(path={path!r}, size={size}, offset={offset}, fh={fh})") node = self._get_node_from_handle(fh) if node is None: - raise mfuse.FuseOSError(errno.EBADF) + raise hlfuse.FuseOSError(errno.EBADF) item = self.get_inode(node.ino) parts = [] @@ -640,7 +639,7 @@ class borgfs(mfuse.Operations, FuseBackend): data = zeros[:s] assert len(data) == s else: - raise mfuse.FuseOSError(errno.EIO) from None + raise hlfuse.FuseOSError(errno.EIO) from None else: _, data = self.repo_objs.parse(id, cdata, ro_type=ROBJ_FILE_STREAM) if offset + n < len(data): @@ -662,7 +661,7 @@ class borgfs(mfuse.Operations, FuseBackend): debug_log(f"readdir(path={path!r}, fh={fh})") node = self._find_node(path) if node is None: - raise mfuse.FuseOSError(errno.ENOENT) + raise hlfuse.FuseOSError(errno.ENOENT) offset = 0 offset += 0 # += 1 @@ -684,7 +683,7 @@ class borgfs(mfuse.Operations, FuseBackend): debug_log(f"readlink(path={path!r})") node = self._find_node(path) if node is None: - raise mfuse.FuseOSError(errno.ENOENT) + raise hlfuse.FuseOSError(errno.ENOENT) item = self.get_inode(node.ino) result = item.target debug_log(f"readlink -> {result!r}")