1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 01:06:50 +00:00

Added hard links support

This commit is contained in:
Jonas Borgström 2013-07-23 13:07:48 +02:00
parent 4f88eac300
commit f4b12a3179

View file

@ -2,11 +2,9 @@
import errno
import llfuse
import os
import stat
import time
# TODO
# - multi archive
# hard links
class AtticOperations(llfuse.Operations):
"""
@ -22,7 +20,7 @@ def __init__(self, key, repository, archive):
self.inode_contents = defaultdict(dict)
for item, _ in archive.iter_items():
head, tail = os.path.split(os.path.normpath(os.fsencode(item[b'path'])))
head, tail = os.path.split(os.fsencode(os.path.normpath(item[b'path'])))
segments = head.split(b'/')
parent = 1
for segment in segments:
@ -36,15 +34,24 @@ def __init__(self, key, repository, archive):
parent = node.st_ino
else:
parent = self.inode_contents[parent][segment]
node = self._make_item_inode(item)
if b'source' in item and stat.S_ISREG(item[b'mode']):
node = self._find_inode(item[b'source'])
else:
node = self._make_item_inode(item)
self.inodes[node.st_ino] = node
self.items[node.st_ino] = item
node.st_nlink += 1
self.inodes[node.st_ino] = node
self.items[node.st_ino] = item
self.inode_parent[node.st_ino] = parent
if tail:
self.inode_contents[parent][tail] = node.st_ino
def _find_inode(self, path):
segments = os.fsencode(os.path.normpath(path)).split(b'/')
inode = 1
for segment in segments:
inode = self.inode_contents[inode][segment]
return self.inodes[inode]
def _make_directory_inode(self):
entry = llfuse.EntryAttributes()
entry.st_ino = len(self.inodes) + 1