1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-23 00:07:38 +00:00

Fix xattr issue when backing up sshfs filesystems (Closes #4).

This commit is contained in:
Jonas Borgström 2013-08-17 12:38:35 +02:00
parent 033dfe1225
commit a84613f0b8
2 changed files with 11 additions and 16 deletions

View file

@ -9,6 +9,7 @@ Version 0.8
(feature release, released on X)
- Fix xattr issue when backing up sshfs filesystems (#4)
- Support access of read only repositories.
- New syntax to enable repository encryption:
attic init --encryption="none|passphrase|keyfile".

View file

@ -18,13 +18,17 @@ def is_enabled():
def get_all(path, follow_symlinks=True):
return dict((name, getxattr(path, name, follow_symlinks=follow_symlinks))
for name in listxattr(path, follow_symlinks=follow_symlinks))
try:
return dict((name, getxattr(path, name, follow_symlinks=follow_symlinks))
for name in listxattr(path, follow_symlinks=follow_symlinks))
except OSError as e:
if e.errno in (errno.ENOTSUP, errno.EPERM):
return {}
try:
# Currently only available on Python 3.3+ on Linux
from os import getxattr, setxattr, listxattr2
from os import getxattr, setxattr, listxattr
except ImportError:
from ctypes import CDLL, create_string_buffer, c_ssize_t, c_size_t, c_char_p, c_int, c_uint32, get_errno
from ctypes.util import find_library
@ -124,12 +128,7 @@ def listxattr(path, *, follow_symlinks=True):
func = libc.flistxattr
elif not follow_symlinks:
flags = XATTR_NOFOLLOW
try:
n = _check(func(path, None, 0, flags), path)
except OSError as e:
if e.errno == errno.EPERM:
return []
raise
n = _check(func(path, None, 0, flags), path)
if n == 0:
return []
namebuf = create_string_buffer(n)
@ -201,12 +200,7 @@ def listxattr(path, *, follow_symlinks=True):
func = libc.extattr_list_file
else:
func = libc.extattr_list_link
try:
n = _check(func(path, ns, None, 0), path)
except OSError as e:
if e.errno == errno.ENOTSUP:
return []
raise
n = _check(func(path, ns, None, 0), path)
if n == 0:
return []
namebuf = create_string_buffer(n)