Skip to content

Commit

Permalink
Merge pull request #5072 from ThomasWaldmann/fix-birthtime-old-llfuse
Browse files Browse the repository at this point in the history
fix crash on old llfuse without birthtime attrs, fixes #5064
  • Loading branch information
ThomasWaldmann committed Apr 3, 2020
2 parents 0c5c3bc + ec5eafd commit f832aa5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/borg/fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit f832aa5

Please sign in to comment.