From ec5eafd4109896c60b652a0022ec27a3d57d255d Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 2 Apr 2020 20:24:23 +0200 Subject: [PATCH] fix crash on old llfuse without birthtime attrs, fixes #5064 e.g. ubuntu xenial has llfuse 0.41, which is older than llfuse 1.3, which introduced birthtime support. --- src/borg/fuse.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/borg/fuse.py b/src/borg/fuse.py index 5b2072a545..06b73dc3bf 100644 --- a/src/borg/fuse.py +++ b/src/borg/fuse.py @@ -28,6 +28,10 @@ # Does this version of llfuse support ns precision? have_fuse_xtime_ns = hasattr(llfuse.EntryAttributes, 'st_mtime_ns') +# Does this version of llfuse support birthtime? +have_fuse_birthtime = hasattr(llfuse.EntryAttributes, 'st_birthtime') # never? +have_fuse_birthtime_ns = hasattr(llfuse.EntryAttributes, 'st_birthtime_ns') # since llfuse 1.3 + fuse_version = LooseVersion(getattr(llfuse, '__version__', '0.1')) if fuse_version >= '0.42': def fuse_main(): @@ -541,12 +545,14 @@ def getattr(self, inode, ctx=None): entry.st_mtime_ns = mtime_ns entry.st_atime_ns = item.get('atime', mtime_ns) entry.st_ctime_ns = item.get('ctime', mtime_ns) - entry.st_birthtime_ns = item.get('birthtime', mtime_ns) + if have_fuse_birthtime_ns: + entry.st_birthtime_ns = item.get('birthtime', mtime_ns) else: entry.st_mtime = mtime_ns / 1e9 entry.st_atime = item.get('atime', mtime_ns) / 1e9 entry.st_ctime = item.get('ctime', mtime_ns) / 1e9 - entry.st_birthtime = item.get('birthtime', mtime_ns) / 1e9 + if have_fuse_birthtime: + entry.st_birthtime = item.get('birthtime', mtime_ns) / 1e9 return entry def listxattr(self, inode, ctx=None):