1
0
mirror of https://github.com/restic/restic.git synced 2024-07-06 09:20:53 +02:00
restic/vendor/github.com/pkg/xattr/xattr_linux.go
Alexander Neumann bff635bc5f Update dependencies, enable pruning for vendor/
So, `dep` got an nice new feature to remove tests and non-go files from
`vendor/`, and this brings the size of the vendor directory from ~300MiB
down to ~20MiB. We don that now.
2018-08-01 21:32:15 +02:00

65 lines
1.5 KiB
Go

// +build linux
package xattr
import (
"syscall"
"golang.org/x/sys/unix"
)
const (
XATTR_CREATE = unix.XATTR_CREATE
XATTR_REPLACE = unix.XATTR_REPLACE
// ENOATTR is not exported by the syscall package on Linux, because it is
// an alias for ENODATA. We export it here so it is available on all
// our supported platforms.
ENOATTR = syscall.ENODATA
)
func getxattr(path string, name string, data []byte) (int, error) {
return unix.Getxattr(path, name, data)
}
func lgetxattr(path string, name string, data []byte) (int, error) {
return unix.Lgetxattr(path, name, data)
}
func setxattr(path string, name string, data []byte, flags int) error {
return unix.Setxattr(path, name, data, flags)
}
func lsetxattr(path string, name string, data []byte, flags int) error {
return unix.Lsetxattr(path, name, data, flags)
}
func removexattr(path string, name string) error {
return unix.Removexattr(path, name)
}
func lremovexattr(path string, name string) error {
return unix.Lremovexattr(path, name)
}
func listxattr(path string, data []byte) (int, error) {
return unix.Listxattr(path, data)
}
func llistxattr(path string, data []byte) (int, error) {
return unix.Llistxattr(path, data)
}
// stringsFromByteSlice converts a sequence of attributes to a []string.
// On Darwin and Linux, each entry is a NULL-terminated string.
func stringsFromByteSlice(buf []byte) (result []string) {
offset := 0
for index, b := range buf {
if b == 0 {
result = append(result, string(buf[offset:index]))
offset = index + 1
}
}
return
}