1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-01-21 23:08:38 +00:00
restic/internal/fs/meta_xattr.go
2024-11-30 19:17:25 +01:00

40 lines
949 B
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) {
xattrs, err := listxattr(p.name)
debug.Log("fillExtendedAttributes(%v) %v %v", p.name, 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(p.name, attr)
if err != nil {
fmt.Fprintf(os.Stderr, "can not obtain extended attribute %v for %v:\n", attr, p.name)
continue
}
attr := restic.ExtendedAttribute{
Name: attr,
Value: attrVal,
}
extendedAttrs = append(extendedAttrs, attr)
}
return extendedAttrs, nil
}