mirror of
https://github.com/restic/restic.git
synced 2025-01-21 06:48:35 +00:00
ea1446f50b
Add the skeleton, but leave filling in the details to later commits.
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
//go:build darwin || freebsd || linux || solaris
|
|
// +build darwin freebsd linux solaris
|
|
|
|
package fs
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/restic/restic/internal/debug"
|
|
"github.com/restic/restic/internal/restic"
|
|
)
|
|
|
|
func (p *pathMetadataHandle) Xattr(ignoreListError bool) ([]restic.ExtendedAttribute, error) {
|
|
return xattrFromPath(p.Name(), ignoreListError)
|
|
}
|
|
|
|
func xattrFromPath(path string, ignoreListError bool) ([]restic.ExtendedAttribute, error) {
|
|
xattrs, err := listxattr(path)
|
|
debug.Log("fillExtendedAttributes(%v) %v %v", path, xattrs, err)
|
|
if err != nil {
|
|
if ignoreListError && isListxattrPermissionError(err) {
|
|
return nil, nil
|
|
}
|
|
return nil, err
|
|
}
|
|
|
|
extendedAttrs := make([]restic.ExtendedAttribute, 0, len(xattrs))
|
|
for _, attr := range xattrs {
|
|
attrVal, err := getxattr(path, attr)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "can not obtain extended attribute %v for %v:\n", attr, path)
|
|
continue
|
|
}
|
|
attr := restic.ExtendedAttribute{
|
|
Name: attr,
|
|
Value: attrVal,
|
|
}
|
|
|
|
extendedAttrs = append(extendedAttrs, attr)
|
|
}
|
|
|
|
return extendedAttrs, nil
|
|
}
|