mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Reuse readlink parameter, add sockaddr max.
PiperOrigin-RevId: 213058623 Change-Id: I522598c655d633b9330990951ff1c54d1023ec29
This commit is contained in:
@@ -140,6 +140,10 @@ const (
|
||||
SO_TYPE = 3
|
||||
)
|
||||
|
||||
// SockAddrMax is the maximum size of a struct sockaddr, from
|
||||
// uapi/linux/socket.h.
|
||||
const SockAddrMax = 128
|
||||
|
||||
// SockAddrInt is struct sockaddr_in, from uapi/linux/in.h.
|
||||
type SockAddrInet struct {
|
||||
Family uint16
|
||||
|
||||
@@ -23,6 +23,9 @@ import (
|
||||
ktime "gvisor.googlesource.com/gvisor/pkg/sentry/kernel/time"
|
||||
)
|
||||
|
||||
// NulByte is a single NUL byte. It is passed to readlinkat as an empty string.
|
||||
var NulByte byte = '\x00'
|
||||
|
||||
func createLink(fd int, name string, linkName string) error {
|
||||
namePtr, err := syscall.BytePtrFromString(name)
|
||||
if err != nil {
|
||||
@@ -50,7 +53,7 @@ func readLink(fd int) (string, error) {
|
||||
n, _, errno := syscall.Syscall6(
|
||||
syscall.SYS_READLINKAT,
|
||||
uintptr(fd),
|
||||
uintptr(unsafe.Pointer(syscall.StringBytePtr(""))),
|
||||
uintptr(unsafe.Pointer(&NulByte)), // ""
|
||||
uintptr(unsafe.Pointer(&b[0])),
|
||||
uintptr(l),
|
||||
0, 0)
|
||||
|
||||
Reference in New Issue
Block a user