mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-27 00:30:18 +00:00
b2099eb3b1
Bumps [k8s.io/kubernetes](https://github.com/kubernetes/kubernetes) from 1.22.3 to 1.22.4. - [Release notes](https://github.com/kubernetes/kubernetes/releases) - [Commits](https://github.com/kubernetes/kubernetes/compare/v1.22.3...v1.22.4) --- updated-dependencies: - dependency-name: k8s.io/kubernetes dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
39 lines
871 B
Go
39 lines
871 B
Go
package selinux
|
|
|
|
import (
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// lgetxattr returns a []byte slice containing the value of
|
|
// an extended attribute attr set for path.
|
|
func lgetxattr(path, attr string) ([]byte, error) {
|
|
// Start with a 128 length byte array
|
|
dest := make([]byte, 128)
|
|
sz, errno := doLgetxattr(path, attr, dest)
|
|
for errno == unix.ERANGE {
|
|
// Buffer too small, use zero-sized buffer to get the actual size
|
|
sz, errno = doLgetxattr(path, attr, []byte{})
|
|
if errno != nil {
|
|
return nil, errno
|
|
}
|
|
|
|
dest = make([]byte, sz)
|
|
sz, errno = doLgetxattr(path, attr, dest)
|
|
}
|
|
if errno != nil {
|
|
return nil, errno
|
|
}
|
|
|
|
return dest[:sz], nil
|
|
}
|
|
|
|
// doLgetxattr is a wrapper that retries on EINTR
|
|
func doLgetxattr(path, attr string, dest []byte) (int, error) {
|
|
for {
|
|
sz, err := unix.Lgetxattr(path, attr, dest)
|
|
if err != unix.EINTR {
|
|
return sz, err
|
|
}
|
|
}
|
|
}
|