mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-04 07:49:35 +00:00 
			
		
		
		
	update cadvisor, docker, and runc godeps
This commit is contained in:
		
							
								
								
									
										88
									
								
								vendor/github.com/opencontainers/runc/libcontainer/system/xattrs_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										88
									
								
								vendor/github.com/opencontainers/runc/libcontainer/system/xattrs_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,99 +1,35 @@
 | 
			
		||||
package system
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"syscall"
 | 
			
		||||
	"unsafe"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var _zero uintptr
 | 
			
		||||
 | 
			
		||||
// Returns the size of xattrs and nil error
 | 
			
		||||
// Requires path, takes allocated []byte or nil as last argument
 | 
			
		||||
func Llistxattr(path string, dest []byte) (size int, err error) {
 | 
			
		||||
	pathBytes, err := syscall.BytePtrFromString(path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return -1, err
 | 
			
		||||
	}
 | 
			
		||||
	var newpathBytes unsafe.Pointer
 | 
			
		||||
	if len(dest) > 0 {
 | 
			
		||||
		newpathBytes = unsafe.Pointer(&dest[0])
 | 
			
		||||
	} else {
 | 
			
		||||
		newpathBytes = unsafe.Pointer(&_zero)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_size, _, errno := syscall.Syscall6(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(newpathBytes), uintptr(len(dest)), 0, 0, 0)
 | 
			
		||||
	size = int(_size)
 | 
			
		||||
	if errno != 0 {
 | 
			
		||||
		return -1, errno
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return size, nil
 | 
			
		||||
}
 | 
			
		||||
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) {
 | 
			
		||||
	var sz int
 | 
			
		||||
	pathBytes, err := syscall.BytePtrFromString(path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	attrBytes, err := syscall.BytePtrFromString(attr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Start with a 128 length byte array
 | 
			
		||||
	sz = 128
 | 
			
		||||
	dest := make([]byte, sz)
 | 
			
		||||
	destBytes := unsafe.Pointer(&dest[0])
 | 
			
		||||
	_sz, _, errno := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0)
 | 
			
		||||
	dest := make([]byte, 128)
 | 
			
		||||
	sz, errno := unix.Lgetxattr(path, attr, dest)
 | 
			
		||||
 | 
			
		||||
	switch {
 | 
			
		||||
	case errno == syscall.ENODATA:
 | 
			
		||||
	case errno == unix.ENODATA:
 | 
			
		||||
		return nil, errno
 | 
			
		||||
	case errno == syscall.ENOTSUP:
 | 
			
		||||
	case errno == unix.ENOTSUP:
 | 
			
		||||
		return nil, errno
 | 
			
		||||
	case errno == syscall.ERANGE:
 | 
			
		||||
	case errno == unix.ERANGE:
 | 
			
		||||
		// 128 byte array might just not be good enough,
 | 
			
		||||
		// A dummy buffer is used ``uintptr(0)`` to get real size
 | 
			
		||||
		// A dummy buffer is used to get the real size
 | 
			
		||||
		// of the xattrs on disk
 | 
			
		||||
		_sz, _, errno = syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(unsafe.Pointer(nil)), uintptr(0), 0, 0)
 | 
			
		||||
		sz = int(_sz)
 | 
			
		||||
		if sz < 0 {
 | 
			
		||||
		sz, errno = unix.Lgetxattr(path, attr, []byte{})
 | 
			
		||||
		if errno != nil {
 | 
			
		||||
			return nil, errno
 | 
			
		||||
		}
 | 
			
		||||
		dest = make([]byte, sz)
 | 
			
		||||
		destBytes := unsafe.Pointer(&dest[0])
 | 
			
		||||
		_sz, _, errno = syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0)
 | 
			
		||||
		if errno != 0 {
 | 
			
		||||
		sz, errno = unix.Lgetxattr(path, attr, dest)
 | 
			
		||||
		if errno != nil {
 | 
			
		||||
			return nil, errno
 | 
			
		||||
		}
 | 
			
		||||
	case errno != 0:
 | 
			
		||||
	case errno != nil:
 | 
			
		||||
		return nil, errno
 | 
			
		||||
	}
 | 
			
		||||
	sz = int(_sz)
 | 
			
		||||
	return dest[:sz], nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Lsetxattr(path string, attr string, data []byte, flags int) error {
 | 
			
		||||
	pathBytes, err := syscall.BytePtrFromString(path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	attrBytes, err := syscall.BytePtrFromString(attr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	var dataBytes unsafe.Pointer
 | 
			
		||||
	if len(data) > 0 {
 | 
			
		||||
		dataBytes = unsafe.Pointer(&data[0])
 | 
			
		||||
	} else {
 | 
			
		||||
		dataBytes = unsafe.Pointer(&_zero)
 | 
			
		||||
	}
 | 
			
		||||
	_, _, errno := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(dataBytes), uintptr(len(data)), uintptr(flags), 0)
 | 
			
		||||
	if errno != 0 {
 | 
			
		||||
		return errno
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user