2017-02-02 11:23:13 +00:00
|
|
|
// +build !openbsd
|
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package restic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
2017-02-16 13:25:56 +00:00
|
|
|
|
|
|
|
"github.com/pkg/xattr"
|
2017-02-02 11:23:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Getxattr retrieves extended attribute data associated with path.
|
|
|
|
func Getxattr(path, name string) ([]byte, error) {
|
2017-02-16 13:25:56 +00:00
|
|
|
b, e := xattr.Getxattr(path, name)
|
2017-02-02 11:23:13 +00:00
|
|
|
if e == syscall.ENOTSUP {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return b, e
|
|
|
|
}
|
|
|
|
|
|
|
|
// Listxattr retrieves a list of names of extended attributes associated with the
|
|
|
|
// given path in the file system.
|
|
|
|
func Listxattr(path string) ([]string, error) {
|
2017-02-16 13:25:56 +00:00
|
|
|
s, e := xattr.Listxattr(path)
|
2017-02-02 11:23:13 +00:00
|
|
|
if e == syscall.ENOTSUP {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return s, e
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setxattr associates name and data together as an attribute of path.
|
|
|
|
func Setxattr(path, name string, data []byte) error {
|
2017-02-16 13:25:56 +00:00
|
|
|
e := xattr.Setxattr(path, name, data)
|
2017-02-02 11:23:13 +00:00
|
|
|
if e == syscall.ENOTSUP {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return e
|
|
|
|
}
|