From 75946e7c584715b5bcff9d96f118b6b8b6ae4ea7 Mon Sep 17 00:00:00 2001
From: Alexander Neumann <alexander@bumpern.de>
Date: Fri, 30 Mar 2018 12:38:37 +0200
Subject: [PATCH] Update vendored library github.com/pkg/xattr

---
 Gopkg.lock                                    |  4 ++--
 vendor/github.com/pkg/xattr/.travis.yml       |  5 +++--
 vendor/github.com/pkg/xattr/README.md         |  2 +-
 vendor/github.com/pkg/xattr/go.mod            |  1 +
 vendor/github.com/pkg/xattr/syscall_darwin.go |  1 -
 vendor/github.com/pkg/xattr/xattr_darwin.go   | 13 +++++++++++--
 vendor/github.com/pkg/xattr/xattr_freebsd.go  | 10 +++++++++-
 vendor/github.com/pkg/xattr/xattr_linux.go    | 12 +++++++++++-
 vendor/github.com/pkg/xattr/xattr_test.go     | 11 ++++++++++-
 9 files changed, 48 insertions(+), 11 deletions(-)
 create mode 100644 vendor/github.com/pkg/xattr/go.mod

diff --git a/Gopkg.lock b/Gopkg.lock
index 75b417ecc..7f698ac5e 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -136,8 +136,8 @@
 [[projects]]
   name = "github.com/pkg/xattr"
   packages = ["."]
-  revision = "23c75e3f6c1d8b13b3dd905b011a7f38a06044b7"
-  version = "v0.2.1"
+  revision = "1d7b7ffe7c46974a836eb583b7452f22de1c18cf"
+  version = "v0.2.3"
 
 [[projects]]
   name = "github.com/restic/chunker"
diff --git a/vendor/github.com/pkg/xattr/.travis.yml b/vendor/github.com/pkg/xattr/.travis.yml
index cbf043c6a..0dac9e3c5 100644
--- a/vendor/github.com/pkg/xattr/.travis.yml
+++ b/vendor/github.com/pkg/xattr/.travis.yml
@@ -2,8 +2,9 @@ language: go
 sudo: false
 
 go:
-  - 1.8
-  - tip
+  - "1.8.x"
+  - "1.9.x"
+  - "1.10"
 
 os:
   - linux
diff --git a/vendor/github.com/pkg/xattr/README.md b/vendor/github.com/pkg/xattr/README.md
index bf370d250..1ec06e822 100644
--- a/vendor/github.com/pkg/xattr/README.md
+++ b/vendor/github.com/pkg/xattr/README.md
@@ -10,7 +10,7 @@ Extended attribute support for Go (linux + darwin + freebsd).
 
 
 ### Example
-```
+```go
   const path = "/tmp/myfile"
   const prefix = "user."
 
diff --git a/vendor/github.com/pkg/xattr/go.mod b/vendor/github.com/pkg/xattr/go.mod
new file mode 100644
index 000000000..0ef796405
--- /dev/null
+++ b/vendor/github.com/pkg/xattr/go.mod
@@ -0,0 +1 @@
+module "github.com/pkg/xattr"
diff --git a/vendor/github.com/pkg/xattr/syscall_darwin.go b/vendor/github.com/pkg/xattr/syscall_darwin.go
index 6fe1f6c10..e20fafd64 100644
--- a/vendor/github.com/pkg/xattr/syscall_darwin.go
+++ b/vendor/github.com/pkg/xattr/syscall_darwin.go
@@ -8,7 +8,6 @@ import (
 )
 
 func getxattr(path string, name string, value *byte, size int, pos int, options int) (int, error) {
-
 	r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(syscall.StringBytePtr(path))), uintptr(unsafe.Pointer(syscall.StringBytePtr(name))), uintptr(unsafe.Pointer(value)), uintptr(size), uintptr(pos), uintptr(options))
 	if e1 != syscall.Errno(0) {
 		return int(r0), e1
diff --git a/vendor/github.com/pkg/xattr/xattr_darwin.go b/vendor/github.com/pkg/xattr/xattr_darwin.go
index 3566b3eac..eed2ebcc3 100644
--- a/vendor/github.com/pkg/xattr/xattr_darwin.go
+++ b/vendor/github.com/pkg/xattr/xattr_darwin.go
@@ -2,6 +2,8 @@
 
 package xattr
 
+import "syscall"
+
 // Get retrieves extended attribute data associated with path.
 func Get(path, name string) ([]byte, error) {
 	// find size.
@@ -30,7 +32,6 @@ func List(path string) ([]string, error) {
 		return nil, &Error{"xattr.List", path, "", err}
 	}
 	if size > 0 {
-
 		buf := make([]byte, size)
 		// Read into buffer of that size.
 		read, err := listxattr(path, &buf[0], size, 0)
@@ -44,7 +45,7 @@ func List(path string) ([]string, error) {
 
 // Set associates name and data together as an attribute of path.
 func Set(path, name string, data []byte) error {
-	var dataval *byte = nil
+	var dataval *byte
 	datalen := len(data)
 	if datalen > 0 {
 		dataval = &data[0]
@@ -62,3 +63,11 @@ func Remove(path, name string) error {
 	}
 	return nil
 }
+
+// Supported checks if filesystem supports extended attributes
+func Supported(path string) bool {
+	if _, err := listxattr(path, nil, 0, 0); err != nil {
+		return err != syscall.ENOTSUP
+	}
+	return true
+}
diff --git a/vendor/github.com/pkg/xattr/xattr_freebsd.go b/vendor/github.com/pkg/xattr/xattr_freebsd.go
index 823fcad8e..ff90573f6 100644
--- a/vendor/github.com/pkg/xattr/xattr_freebsd.go
+++ b/vendor/github.com/pkg/xattr/xattr_freebsd.go
@@ -51,7 +51,7 @@ func List(path string) ([]string, error) {
 
 // Set associates name and data together as an attribute of path.
 func Set(path, name string, data []byte) error {
-	var dataval *byte = nil
+	var dataval *byte
 	datalen := len(data)
 	if datalen > 0 {
 		dataval = &data[0]
@@ -74,6 +74,14 @@ func Remove(path, name string) error {
 	return nil
 }
 
+// Supported checks if filesystem supports extended attributes
+func Supported(path string) bool {
+	if _, err := extattr_list_file(path, EXTATTR_NAMESPACE_USER, nil, 0); err != nil {
+		return err != syscall.ENOTSUP
+	}
+	return true
+}
+
 // attrListToStrings converts a sequnce of attribute name entries to a []string.
 // Each entry consists of a single byte containing the length
 // of the attribute name, followed by the attribute name.
diff --git a/vendor/github.com/pkg/xattr/xattr_linux.go b/vendor/github.com/pkg/xattr/xattr_linux.go
index e4a6313f6..62ad4eef2 100644
--- a/vendor/github.com/pkg/xattr/xattr_linux.go
+++ b/vendor/github.com/pkg/xattr/xattr_linux.go
@@ -32,7 +32,9 @@ func List(path string) ([]string, error) {
 		return nil, &Error{"xattr.List", path, "", err}
 	}
 	if size > 0 {
-		buf := make([]byte, size)
+		// `size + 1` because of ERANGE error when reading
+		// 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 := syscall.Listxattr(path, buf)
 		if err != nil {
@@ -59,3 +61,11 @@ func Remove(path, name string) error {
 	}
 	return nil
 }
+
+// Supported checks if filesystem supports extended attributes
+func Supported(path string) bool {
+	if _, err := syscall.Listxattr(path, nil); err != nil {
+		return err != syscall.ENOTSUP
+	}
+	return true
+}
diff --git a/vendor/github.com/pkg/xattr/xattr_test.go b/vendor/github.com/pkg/xattr/xattr_test.go
index d7f4d731d..c192b7cb4 100644
--- a/vendor/github.com/pkg/xattr/xattr_test.go
+++ b/vendor/github.com/pkg/xattr/xattr_test.go
@@ -12,12 +12,16 @@ const UserPrefix = "user."
 
 func Test(t *testing.T) {
 	tmp, err := ioutil.TempFile("", "")
-
 	if err != nil {
 		t.Fatal(err)
 	}
 	defer os.Remove(tmp.Name())
 
+	// Check if filesystem supports extended attributes
+	if !Supported(tmp.Name()) {
+		t.Skip("Skipping test - filesystem does not support extended attributes")
+	}
+
 	err = Set(tmp.Name(), UserPrefix+"test", []byte("test-attr-value"))
 	if err != nil {
 		t.Fatal(err)
@@ -63,6 +67,11 @@ func TestNoData(t *testing.T) {
 	}
 	defer os.Remove(tmp.Name())
 
+	// Check if filesystem supports extended attributes
+	if !Supported(tmp.Name()) {
+		t.Skip("Skipping test - filesystem does not support extended attributes")
+	}
+
 	err = Set(tmp.Name(), UserPrefix+"test", []byte{})
 	if err != nil {
 		t.Fatal(err)