mirror of
https://github.com/containers/podman.git
synced 2025-12-02 19:28:58 +08:00
Vendor in containers/(storage,image, common, buildah)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
20
vendor/github.com/containers/buildah/copier/xattrs.go
generated
vendored
20
vendor/github.com/containers/buildah/copier/xattrs.go
generated
vendored
@@ -1,13 +1,15 @@
|
||||
//go:build linux || netbsd || freebsd || darwin
|
||||
// +build linux netbsd freebsd darwin
|
||||
|
||||
package copier
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/containers/buildah/util"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -43,22 +45,22 @@ func Lgetxattrs(path string) (map[string]string, error) {
|
||||
list = make([]byte, listSize)
|
||||
size, err := unix.Llistxattr(path, list)
|
||||
if err != nil {
|
||||
if unwrapError(err) == syscall.ERANGE {
|
||||
if util.Cause(err) == syscall.ERANGE {
|
||||
listSize *= 2
|
||||
continue
|
||||
}
|
||||
if (unwrapError(err) == syscall.ENOTSUP) || (unwrapError(err) == syscall.ENOSYS) {
|
||||
if (util.Cause(err) == syscall.ENOTSUP) || (util.Cause(err) == syscall.ENOSYS) {
|
||||
// treat these errors listing xattrs as equivalent to "no xattrs"
|
||||
list = list[:0]
|
||||
break
|
||||
}
|
||||
return nil, errors.Wrapf(err, "error listing extended attributes of %q", path)
|
||||
return nil, fmt.Errorf("error listing extended attributes of %q: %w", path, err)
|
||||
}
|
||||
list = list[:size]
|
||||
break
|
||||
}
|
||||
if listSize >= maxSize {
|
||||
return nil, errors.Errorf("unable to read list of attributes for %q: size would have been too big", path)
|
||||
return nil, fmt.Errorf("unable to read list of attributes for %q: size would have been too big", path)
|
||||
}
|
||||
m := make(map[string]string)
|
||||
for _, attribute := range strings.Split(string(list), string('\000')) {
|
||||
@@ -69,17 +71,17 @@ func Lgetxattrs(path string) (map[string]string, error) {
|
||||
attributeValue = make([]byte, attributeSize)
|
||||
size, err := unix.Lgetxattr(path, attribute, attributeValue)
|
||||
if err != nil {
|
||||
if unwrapError(err) == syscall.ERANGE {
|
||||
if util.Cause(err) == syscall.ERANGE {
|
||||
attributeSize *= 2
|
||||
continue
|
||||
}
|
||||
return nil, errors.Wrapf(err, "error getting value of extended attribute %q on %q", attribute, path)
|
||||
return nil, fmt.Errorf("error getting value of extended attribute %q on %q: %w", attribute, path, err)
|
||||
}
|
||||
m[attribute] = string(attributeValue[:size])
|
||||
break
|
||||
}
|
||||
if attributeSize >= maxSize {
|
||||
return nil, errors.Errorf("unable to read attribute %q of %q: size would have been too big", attribute, path)
|
||||
return nil, fmt.Errorf("unable to read attribute %q of %q: size would have been too big", attribute, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +93,7 @@ func Lsetxattrs(path string, xattrs map[string]string) error {
|
||||
for attribute, value := range xattrs {
|
||||
if isRelevantXattr(attribute) {
|
||||
if err := unix.Lsetxattr(path, attribute, []byte(value), 0); err != nil {
|
||||
return errors.Wrapf(err, "error setting value of extended attribute %q on %q", attribute, path)
|
||||
return fmt.Errorf("error setting value of extended attribute %q on %q: %w", attribute, path, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user