bugfix: omit ENOTDATA for extended attributes

Signed-off-by: hoyho <luohaihao@gmail.com>
This commit is contained in:
hoyho 2020-11-10 00:20:34 +08:00
parent 96a912b65a
commit 9df52327cc
2 changed files with 14 additions and 3 deletions

View file

@ -0,0 +1,8 @@
Bugfix: Ignore 'no data available' error during backup
restic failed to backup files on some filesystems, for example certain configurations
of CIFS on Linux, which return a "no data available" error when reading extended
attributes. These errors are now ignored.
https://github.com/restic/restic/issues/1800
https://github.com/restic/restic/pull/3034

View file

@ -16,7 +16,8 @@ import (
// Getxattr retrieves extended attribute data associated with path.
func Getxattr(path, name string) ([]byte, error) {
b, e := xattr.Get(path, name)
if err, ok := e.(*xattr.Error); ok && err.Err == syscall.ENOTSUP {
if err, ok := e.(*xattr.Error); ok &&
(err.Err == syscall.ENOTSUP || err.Err == xattr.ENOATTR) {
return nil, nil
}
return b, errors.Wrap(e, "Getxattr")
@ -26,7 +27,8 @@ func Getxattr(path, name string) ([]byte, error) {
// given path in the file system.
func Listxattr(path string) ([]string, error) {
s, e := xattr.List(path)
if err, ok := e.(*xattr.Error); ok && err.Err == syscall.ENOTSUP {
if err, ok := e.(*xattr.Error); ok &&
(err.Err == syscall.ENOTSUP || err.Err == xattr.ENOATTR) {
return nil, nil
}
return s, errors.Wrap(e, "Listxattr")
@ -35,7 +37,8 @@ func Listxattr(path string) ([]string, error) {
// Setxattr associates name and data together as an attribute of path.
func Setxattr(path, name string, data []byte) error {
e := xattr.Set(path, name, data)
if err, ok := e.(*xattr.Error); ok && err.Err == syscall.ENOTSUP {
if err, ok := e.(*xattr.Error); ok &&
(err.Err == syscall.ENOTSUP || err.Err == xattr.ENOATTR) {
return nil
}
return errors.Wrap(e, "Setxattr")