mirror of
https://github.com/containers/skopeo.git
synced 2025-09-21 09:57:19 +00:00
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.16.2 to 1.16.3. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/master/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.16.2...v1.16.3) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Miloslav Trmač <mitr@redhat.com>
31 lines
700 B
Go
31 lines
700 B
Go
// +build selinux,linux
|
|
|
|
package selinux
|
|
|
|
import (
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// Returns a []byte slice if the xattr is set and nil otherwise
|
|
// Requires path and its attribute as arguments
|
|
func lgetxattr(path string, attr string) ([]byte, error) {
|
|
// Start with a 128 length byte array
|
|
dest := make([]byte, 128)
|
|
sz, errno := unix.Lgetxattr(path, attr, dest)
|
|
for errno == unix.ERANGE {
|
|
// Buffer too small, use zero-sized buffer to get the actual size
|
|
sz, errno = unix.Lgetxattr(path, attr, []byte{})
|
|
if errno != nil {
|
|
return nil, errno
|
|
}
|
|
|
|
dest = make([]byte, sz)
|
|
sz, errno = unix.Lgetxattr(path, attr, dest)
|
|
}
|
|
if errno != nil {
|
|
return nil, errno
|
|
}
|
|
|
|
return dest[:sz], nil
|
|
}
|