Update dependencies

Closes #2129
This commit is contained in:
Alexander Neumann
2019-01-27 21:07:57 +01:00
parent aa7043151a
commit b9f0f031b6
672 changed files with 116946 additions and 13086 deletions
+3
View File
@@ -18,6 +18,9 @@ _cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
# Dependencies
go.sum
_testmain.go
*.exe
+1 -1
View File
@@ -11,4 +11,4 @@ GOOS=freebsd go build
echo "Running tests..."
go vet
go test -v -race -covermode=atomic
go test -v -race -coverprofile=coverage.txt -covermode=atomic
+9 -8
View File
@@ -2,22 +2,23 @@ language: go
sudo: false
go:
- "1.8.x"
- "1.9.x"
- "1.10"
- "1.11"
os:
- linux
- osx
install:
before_install:
- go version
- export GOBIN="$GOPATH/bin"
- export PATH="$PATH:$GOBIN"
- go get golang.org/x/sys/unix
- export GO111MODULE=on
- go get golang.org/x/tools/cmd/goimports
install:
- go build
script:
- ./.travis.sh
- diff <(GOPATH="$PWD:$PWD/vendor" goimports -d .) <(printf "")
- diff <(goimports -d .) <(printf "")
after_success:
- bash <(curl -s https://codecov.io/bash)
+3 -2
View File
@@ -2,6 +2,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/pkg/xattr)](https://goreportcard.com/report/github.com/pkg/xattr)
[![Build Status](https://travis-ci.org/pkg/xattr.svg?branch=master)](https://travis-ci.org/pkg/xattr)
[![Version](https://badge.fury.io/gh/pkg%2Fxattr.svg)](https://github.com/pkg/xattr/releases)
[![Codecov](https://codecov.io/gh/pkg/xattr/branch/master/graph/badge.svg)](https://codecov.io/gh/pkg/xattr)
xattr
=====
@@ -23,12 +24,12 @@ do not reference a symlink that appears at the end of a path. See
if err := xattr.Set(path, prefix+"test", []byte("test-attr-value")); err != nil {
log.Fatal(err)
}
var list []string
if list, err = xattr.List(path); err != nil {
log.Fatal(err)
}
var data []byte
if data, err = xattr.Get(path, prefix+"test"); err != nil {
log.Fatal(err)
+1 -1
View File
@@ -1,3 +1,3 @@
module github.com/pkg/xattr
require golang.org/x/sys v0.0.0-20180525142821-c11f84a56e43
require golang.org/x/sys v0.0.0-20181021155630-eda9bb28ed51
-1
View File
@@ -1 +0,0 @@
golang.org/x/sys v0.0.0-20180525142821-c11f84a56e43/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+60 -12
View File
@@ -5,10 +5,11 @@ similar to the environment strings associated with a process.
An attribute may be defined or undefined. If it is defined, its value may be empty or non-empty.
More details you can find here: https://en.wikipedia.org/wiki/Extended_file_attributes .
All functions are provided in pairs: Get/LGet, Set/LSet etc. The "L"
variant will not follow a symlink at the end of the path.
All functions are provided in triples: Get/LGet/FGet, Set/LSet/FSet etc. The "L"
variant will not follow a symlink at the end of the path, and "F" variant accepts
a file descriptor instead of a path.
Example assuming path is "/symlink1/symlink2", where both components are
Example for "L" variant, assuming path is "/symlink1/symlink2", where both components are
symlinks:
Get will follow "symlink1" and "symlink2" and operate on the target of
"symlink2". LGet will follow "symlink1" but operate directly on "symlink2".
@@ -16,6 +17,7 @@ Get will follow "symlink1" and "symlink2" and operate on the target of
package xattr
import (
"os"
"syscall"
)
@@ -34,15 +36,26 @@ func (e *Error) Error() string {
// Get retrieves extended attribute data associated with path. It will follow
// all symlinks along the path.
func Get(path, name string) ([]byte, error) {
return get(path, name, getxattr)
return get(path, name, func(name string, data []byte) (int, error) {
return getxattr(path, name, data)
})
}
// LGet is like Get but does not follow a symlink at the end of the path.
func LGet(path, name string) ([]byte, error) {
return get(path, name, lgetxattr)
return get(path, name, func(name string, data []byte) (int, error) {
return lgetxattr(path, name, data)
})
}
type getxattrFunc func(path string, name string, data []byte) (int, error)
// FGet is like Get but accepts a os.File instead of a file path.
func FGet(f *os.File, name string) ([]byte, error) {
return get(f.Name(), name, func(name string, data []byte) (int, error) {
return fgetxattr(f, name, data)
})
}
type getxattrFunc func(name string, data []byte) (int, error)
// get contains the buffer allocation logic used by both Get and LGet.
func get(path string, name string, getxattrFunc getxattrFunc) ([]byte, error) {
@@ -62,7 +75,7 @@ func get(path string, name string, getxattrFunc getxattrFunc) ([]byte, error) {
size := initialBufSize
for {
data := make([]byte, size)
read, err := getxattrFunc(path, name, data)
read, err := getxattrFunc(name, data)
// If the buffer was too small to fit the value, Linux and MacOS react
// differently:
@@ -105,6 +118,14 @@ func LSet(path, name string, data []byte) error {
return nil
}
// FSet is like Set but accepts a os.File instead of a file path.
func FSet(f *os.File, name string, data []byte) error {
if err := fsetxattr(f, name, data, 0); err != nil {
return &Error{"xattr.FSet", f.Name(), name, err}
}
return nil
}
// SetWithFlags associates name and data together as an attribute of path.
// Forwards the flags parameter to the syscall layer.
func SetWithFlags(path, name string, data []byte, flags int) error {
@@ -123,6 +144,14 @@ func LSetWithFlags(path, name string, data []byte, flags int) error {
return nil
}
// FSetWithFlags is like SetWithFlags but accepts a os.File instead of a file path.
func FSetWithFlags(f *os.File, name string, data []byte, flags int) error {
if err := fsetxattr(f, name, data, flags); err != nil {
return &Error{"xattr.FSetWithFlags", f.Name(), name, err}
}
return nil
}
// Remove removes the attribute associated with the given path.
func Remove(path, name string) error {
if err := removexattr(path, name); err != nil {
@@ -140,25 +169,44 @@ func LRemove(path, name string) error {
return nil
}
// FRemove is like Remove but accepts a os.File instead of a file path.
func FRemove(f *os.File, name string) error {
if err := fremovexattr(f, name); err != nil {
return &Error{"xattr.FRemove", f.Name(), name, err}
}
return nil
}
// List retrieves a list of names of extended attributes associated
// with the given path in the file system.
func List(path string) ([]string, error) {
return list(path, listxattr)
return list(path, func(data []byte) (int, error) {
return listxattr(path, data)
})
}
// LList is like List but does not follow a symlink at the end of the
// path.
func LList(path string) ([]string, error) {
return list(path, llistxattr)
return list(path, func(data []byte) (int, error) {
return llistxattr(path, data)
})
}
type listxattrFunc func(path string, data []byte) (int, error)
// FList is like List but accepts a os.File instead of a file path.
func FList(f *os.File) ([]string, error) {
return list(f.Name(), func(data []byte) (int, error) {
return flistxattr(f, data)
})
}
type listxattrFunc func(data []byte) (int, error)
// list contains the buffer allocation logic used by both List and LList.
func list(path string, listxattrFunc listxattrFunc) ([]string, error) {
myname := "xattr.list"
// find size.
size, err := listxattrFunc(path, nil)
size, err := listxattrFunc(nil)
if err != nil {
return nil, &Error{myname, path, "", err}
}
@@ -167,7 +215,7 @@ func list(path string, listxattrFunc listxattrFunc) ([]string, error) {
// from a SMB1 mount point (https://github.com/pkg/xattr/issues/16).
buf := make([]byte, size+1)
// Read into buffer of that size.
read, err := listxattrFunc(path, buf)
read, err := listxattrFunc(buf)
if err != nil {
return nil, &Error{myname, path, "", err}
}
+17
View File
@@ -3,6 +3,7 @@
package xattr
import (
"os"
"syscall"
"unsafe"
@@ -48,6 +49,10 @@ func lgetxattr(path string, name string, data []byte) (int, error) {
return int(r0), nil
}
func fgetxattr(f *os.File, name string, data []byte) (int, error) {
return getxattr(f.Name(), name, data)
}
func setxattr(path string, name string, data []byte, flags int) error {
return unix.Setxattr(path, name, data, flags)
}
@@ -56,6 +61,10 @@ func lsetxattr(path string, name string, data []byte, flags int) error {
return unix.Setxattr(path, name, data, flags|XATTR_NOFOLLOW)
}
func fsetxattr(f *os.File, name string, data []byte, flags int) error {
return setxattr(f.Name(), name, data, flags)
}
func removexattr(path string, name string) error {
return unix.Removexattr(path, name)
}
@@ -76,6 +85,10 @@ func lremovexattr(path string, name string) error {
return nil
}
func fremovexattr(f *os.File, name string) error {
return removexattr(f.Name(), name)
}
func listxattr(path string, data []byte) (int, error) {
return unix.Listxattr(path, data)
}
@@ -98,6 +111,10 @@ func llistxattr(path string, data []byte) (int, error) {
return int(r0), nil
}
func flistxattr(f *os.File, data []byte) (int, error) {
return listxattr(f.Name(), 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) {
+17
View File
@@ -3,6 +3,7 @@
package xattr
import (
"os"
"syscall"
"unsafe"
)
@@ -24,6 +25,10 @@ func lgetxattr(path string, name string, data []byte) (int, error) {
return sysGet(syscall.SYS_EXTATTR_GET_LINK, path, name, data)
}
func fgetxattr(f *os.File, name string, data []byte) (int, error) {
return getxattr(f.Name(), name, data)
}
// sysGet is called by getxattr and lgetxattr with the appropriate syscall
// number. This works because syscalls have the same signature and return
// values.
@@ -61,6 +66,10 @@ func lsetxattr(path string, name string, data []byte, flags int) error {
return sysSet(syscall.SYS_EXTATTR_SET_LINK, path, name, data)
}
func fsetxattr(f *os.File, name string, data []byte, flags int) error {
return setxattr(f.Name(), name, data, flags)
}
// sysSet is called by setxattr and lsetxattr with the appropriate syscall
// number. This works because syscalls have the same signature and return
// values.
@@ -103,6 +112,10 @@ func lremovexattr(path string, name string) error {
return sysRemove(syscall.SYS_EXTATTR_DELETE_LINK, path, name)
}
func fremovexattr(f *os.File, name string) error {
return removexattr(f.Name(), name)
}
// sysSet is called by removexattr and lremovexattr with the appropriate syscall
// number. This works because syscalls have the same signature and return
// values.
@@ -137,6 +150,10 @@ func llistxattr(path string, data []byte) (int, error) {
return sysList(syscall.SYS_EXTATTR_LIST_LINK, path, data)
}
func flistxattr(f *os.File, data []byte) (int, error) {
return listxattr(f.Name(), data)
}
// sysSet is called by listxattr and llistxattr with the appropriate syscall
// number. This works because syscalls have the same signature and return
// values.
+17
View File
@@ -3,6 +3,7 @@
package xattr
import (
"os"
"syscall"
"golang.org/x/sys/unix"
@@ -26,6 +27,10 @@ func lgetxattr(path string, name string, data []byte) (int, error) {
return unix.Lgetxattr(path, name, data)
}
func fgetxattr(f *os.File, name string, data []byte) (int, error) {
return unix.Fgetxattr(int(f.Fd()), name, data)
}
func setxattr(path string, name string, data []byte, flags int) error {
return unix.Setxattr(path, name, data, flags)
}
@@ -34,6 +39,10 @@ func lsetxattr(path string, name string, data []byte, flags int) error {
return unix.Lsetxattr(path, name, data, flags)
}
func fsetxattr(f *os.File, name string, data []byte, flags int) error {
return unix.Fsetxattr(int(f.Fd()), name, data, flags)
}
func removexattr(path string, name string) error {
return unix.Removexattr(path, name)
}
@@ -42,6 +51,10 @@ func lremovexattr(path string, name string) error {
return unix.Lremovexattr(path, name)
}
func fremovexattr(f *os.File, name string) error {
return unix.Fremovexattr(int(f.Fd()), name)
}
func listxattr(path string, data []byte) (int, error) {
return unix.Listxattr(path, data)
}
@@ -50,6 +63,10 @@ func llistxattr(path string, data []byte) (int, error) {
return unix.Llistxattr(path, data)
}
func flistxattr(f *os.File, data []byte) (int, error) {
return unix.Flistxattr(int(f.Fd()), 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) {