mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-05 08:37:31 -04:00
unix: migrate some illumos definitions to solaris
Fixes golang/go#56000 Change-Id: Ica6549385ddb466c4697cc45851e2b59fd6e0f24 Reviewed-on: https://go-review.googlesource.com/c/sys/+/437357 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
committed by
Gopher Robot
parent
84dc82d7e8
commit
68d869b943
@@ -10,8 +10,6 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"runtime"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -79,107 +77,3 @@ func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error)
|
|
||||||
|
|
||||||
func Putmsg(fd int, cl []byte, data []byte, flags int) (err error) {
|
|
||||||
var clp, datap *strbuf
|
|
||||||
if len(cl) > 0 {
|
|
||||||
clp = &strbuf{
|
|
||||||
Len: int32(len(cl)),
|
|
||||||
Buf: (*int8)(unsafe.Pointer(&cl[0])),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(data) > 0 {
|
|
||||||
datap = &strbuf{
|
|
||||||
Len: int32(len(data)),
|
|
||||||
Buf: (*int8)(unsafe.Pointer(&data[0])),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return putmsg(fd, clp, datap, flags)
|
|
||||||
}
|
|
||||||
|
|
||||||
//sys getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error)
|
|
||||||
|
|
||||||
func Getmsg(fd int, cl []byte, data []byte) (retCl []byte, retData []byte, flags int, err error) {
|
|
||||||
var clp, datap *strbuf
|
|
||||||
if len(cl) > 0 {
|
|
||||||
clp = &strbuf{
|
|
||||||
Maxlen: int32(len(cl)),
|
|
||||||
Buf: (*int8)(unsafe.Pointer(&cl[0])),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(data) > 0 {
|
|
||||||
datap = &strbuf{
|
|
||||||
Maxlen: int32(len(data)),
|
|
||||||
Buf: (*int8)(unsafe.Pointer(&data[0])),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = getmsg(fd, clp, datap, &flags); err != nil {
|
|
||||||
return nil, nil, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(cl) > 0 {
|
|
||||||
retCl = cl[:clp.Len]
|
|
||||||
}
|
|
||||||
if len(data) > 0 {
|
|
||||||
retData = data[:datap.Len]
|
|
||||||
}
|
|
||||||
return retCl, retData, flags, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlSetIntRetInt(fd int, req uint, arg int) (int, error) {
|
|
||||||
return ioctlRet(fd, req, uintptr(arg))
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlSetString(fd int, req uint, val string) error {
|
|
||||||
bs := make([]byte, len(val)+1)
|
|
||||||
copy(bs[:len(bs)-1], val)
|
|
||||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&bs[0])))
|
|
||||||
runtime.KeepAlive(&bs[0])
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lifreq Helpers
|
|
||||||
|
|
||||||
func (l *Lifreq) SetName(name string) error {
|
|
||||||
if len(name) >= len(l.Name) {
|
|
||||||
return fmt.Errorf("name cannot be more than %d characters", len(l.Name)-1)
|
|
||||||
}
|
|
||||||
for i := range name {
|
|
||||||
l.Name[i] = int8(name[i])
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *Lifreq) SetLifruInt(d int) {
|
|
||||||
*(*int)(unsafe.Pointer(&l.Lifru[0])) = d
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *Lifreq) GetLifruInt() int {
|
|
||||||
return *(*int)(unsafe.Pointer(&l.Lifru[0]))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *Lifreq) SetLifruUint(d uint) {
|
|
||||||
*(*uint)(unsafe.Pointer(&l.Lifru[0])) = d
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *Lifreq) GetLifruUint() uint {
|
|
||||||
return *(*uint)(unsafe.Pointer(&l.Lifru[0]))
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlLifreq(fd int, req uint, l *Lifreq) error {
|
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(l)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strioctl Helpers
|
|
||||||
|
|
||||||
func (s *Strioctl) SetInt(i int) {
|
|
||||||
s.Len = int32(unsafe.Sizeof(i))
|
|
||||||
s.Dp = (*int8)(unsafe.Pointer(&i))
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlSetStrioctlRetInt(fd int, req uint, s *Strioctl) (int, error) {
|
|
||||||
return ioctlRet(fd, req, uintptr(unsafe.Pointer(s)))
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
// Copyright 2021 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
//go:build illumos
|
|
||||||
// +build illumos
|
|
||||||
|
|
||||||
package unix_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os/exec"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestLifreqSetName(t *testing.T) {
|
|
||||||
var l unix.Lifreq
|
|
||||||
err := l.SetName("12345678901234356789012345678901234567890")
|
|
||||||
if err == nil {
|
|
||||||
t.Fatal(`Lifreq.SetName should reject names that are too long`)
|
|
||||||
}
|
|
||||||
err = l.SetName("tun0")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf(`Lifreq.SetName("tun0") failed: %v`, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLifreqGetMTU(t *testing.T) {
|
|
||||||
// Find links and their MTU using CLI tooling
|
|
||||||
// $ dladm show-link -p -o link,mtu
|
|
||||||
// net0:1500
|
|
||||||
out, err := exec.Command("dladm", "show-link", "-p", "-o", "link,mtu").Output()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unable to use dladm to find data links: %v", err)
|
|
||||||
}
|
|
||||||
lines := strings.Split(string(out), "\n")
|
|
||||||
tc := make(map[string]string)
|
|
||||||
for _, line := range lines {
|
|
||||||
v := strings.Split(line, ":")
|
|
||||||
if len(v) == 2 {
|
|
||||||
tc[v[0]] = v[1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ip_fd, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, 0)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("could not open udp socket: %v", err)
|
|
||||||
}
|
|
||||||
// SIOCGLIFMTU is negative which confuses the compiler if used inline:
|
|
||||||
// Using "unix.IoctlLifreq(ip_fd, unix.SIOCGLIFMTU, &l)" results in
|
|
||||||
// "constant -1065850502 overflows uint"
|
|
||||||
reqnum := int(unix.SIOCGLIFMTU)
|
|
||||||
var l unix.Lifreq
|
|
||||||
for link, mtu := range tc {
|
|
||||||
err = l.SetName(link)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Lifreq.SetName(%q) failed: %v", link, err)
|
|
||||||
}
|
|
||||||
if err = unix.IoctlLifreq(ip_fd, uint(reqnum), &l); err != nil {
|
|
||||||
t.Fatalf("unable to SIOCGLIFMTU: %v", err)
|
|
||||||
}
|
|
||||||
m := l.GetLifruUint()
|
|
||||||
if fmt.Sprintf("%d", m) != mtu {
|
|
||||||
t.Errorf("unable to read MTU correctly: expected %s, got %d", mtu, m)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1026,3 +1026,107 @@ func (e *EventPort) Get(s []PortEvent, min int, timeout *Timespec) (int, error)
|
|||||||
}
|
}
|
||||||
return valid, err
|
return valid, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error)
|
||||||
|
|
||||||
|
func Putmsg(fd int, cl []byte, data []byte, flags int) (err error) {
|
||||||
|
var clp, datap *strbuf
|
||||||
|
if len(cl) > 0 {
|
||||||
|
clp = &strbuf{
|
||||||
|
Len: int32(len(cl)),
|
||||||
|
Buf: (*int8)(unsafe.Pointer(&cl[0])),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(data) > 0 {
|
||||||
|
datap = &strbuf{
|
||||||
|
Len: int32(len(data)),
|
||||||
|
Buf: (*int8)(unsafe.Pointer(&data[0])),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return putmsg(fd, clp, datap, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error)
|
||||||
|
|
||||||
|
func Getmsg(fd int, cl []byte, data []byte) (retCl []byte, retData []byte, flags int, err error) {
|
||||||
|
var clp, datap *strbuf
|
||||||
|
if len(cl) > 0 {
|
||||||
|
clp = &strbuf{
|
||||||
|
Maxlen: int32(len(cl)),
|
||||||
|
Buf: (*int8)(unsafe.Pointer(&cl[0])),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(data) > 0 {
|
||||||
|
datap = &strbuf{
|
||||||
|
Maxlen: int32(len(data)),
|
||||||
|
Buf: (*int8)(unsafe.Pointer(&data[0])),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = getmsg(fd, clp, datap, &flags); err != nil {
|
||||||
|
return nil, nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(cl) > 0 {
|
||||||
|
retCl = cl[:clp.Len]
|
||||||
|
}
|
||||||
|
if len(data) > 0 {
|
||||||
|
retData = data[:datap.Len]
|
||||||
|
}
|
||||||
|
return retCl, retData, flags, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlSetIntRetInt(fd int, req uint, arg int) (int, error) {
|
||||||
|
return ioctlRet(fd, req, uintptr(arg))
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlSetString(fd int, req uint, val string) error {
|
||||||
|
bs := make([]byte, len(val)+1)
|
||||||
|
copy(bs[:len(bs)-1], val)
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&bs[0])))
|
||||||
|
runtime.KeepAlive(&bs[0])
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lifreq Helpers
|
||||||
|
|
||||||
|
func (l *Lifreq) SetName(name string) error {
|
||||||
|
if len(name) >= len(l.Name) {
|
||||||
|
return fmt.Errorf("name cannot be more than %d characters", len(l.Name)-1)
|
||||||
|
}
|
||||||
|
for i := range name {
|
||||||
|
l.Name[i] = int8(name[i])
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Lifreq) SetLifruInt(d int) {
|
||||||
|
*(*int)(unsafe.Pointer(&l.Lifru[0])) = d
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Lifreq) GetLifruInt() int {
|
||||||
|
return *(*int)(unsafe.Pointer(&l.Lifru[0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Lifreq) SetLifruUint(d uint) {
|
||||||
|
*(*uint)(unsafe.Pointer(&l.Lifru[0])) = d
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Lifreq) GetLifruUint() uint {
|
||||||
|
return *(*uint)(unsafe.Pointer(&l.Lifru[0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlLifreq(fd int, req uint, l *Lifreq) error {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(l)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strioctl Helpers
|
||||||
|
|
||||||
|
func (s *Strioctl) SetInt(i int) {
|
||||||
|
s.Len = int32(unsafe.Sizeof(i))
|
||||||
|
s.Dp = (*int8)(unsafe.Pointer(&i))
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlSetStrioctlRetInt(fd int, req uint, s *Strioctl) (int, error) {
|
||||||
|
return ioctlRet(fd, req, uintptr(unsafe.Pointer(s)))
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@@ -331,3 +332,55 @@ func TestPortEventSlices(t *testing.T) {
|
|||||||
t.Errorf("port.Close() failed: %v", err)
|
t.Errorf("port.Close() failed: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLifreqSetName(t *testing.T) {
|
||||||
|
var l unix.Lifreq
|
||||||
|
err := l.SetName("12345678901234356789012345678901234567890")
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal(`Lifreq.SetName should reject names that are too long`)
|
||||||
|
}
|
||||||
|
err = l.SetName("tun0")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf(`Lifreq.SetName("tun0") failed: %v`, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLifreqGetMTU(t *testing.T) {
|
||||||
|
// Find links and their MTU using CLI tooling
|
||||||
|
// $ dladm show-link -p -o link,mtu
|
||||||
|
// net0:1500
|
||||||
|
out, err := exec.Command("dladm", "show-link", "-p", "-o", "link,mtu").Output()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to use dladm to find data links: %v", err)
|
||||||
|
}
|
||||||
|
lines := strings.Split(string(out), "\n")
|
||||||
|
tc := make(map[string]string)
|
||||||
|
for _, line := range lines {
|
||||||
|
v := strings.Split(line, ":")
|
||||||
|
if len(v) == 2 {
|
||||||
|
tc[v[0]] = v[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ip_fd, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, 0)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("could not open udp socket: %v", err)
|
||||||
|
}
|
||||||
|
// SIOCGLIFMTU is negative which confuses the compiler if used inline:
|
||||||
|
// Using "unix.IoctlLifreq(ip_fd, unix.SIOCGLIFMTU, &l)" results in
|
||||||
|
// "constant -1065850502 overflows uint"
|
||||||
|
reqnum := int(unix.SIOCGLIFMTU)
|
||||||
|
var l unix.Lifreq
|
||||||
|
for link, mtu := range tc {
|
||||||
|
err = l.SetName(link)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Lifreq.SetName(%q) failed: %v", link, err)
|
||||||
|
}
|
||||||
|
if err = unix.IoctlLifreq(ip_fd, uint(reqnum), &l); err != nil {
|
||||||
|
t.Fatalf("unable to SIOCGLIFMTU: %v", err)
|
||||||
|
}
|
||||||
|
m := l.GetLifruUint()
|
||||||
|
if fmt.Sprintf("%d", m) != mtu {
|
||||||
|
t.Errorf("unable to read MTU correctly: expected %s, got %d", mtu, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
// Copyright 2021 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
//go:build ignore
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
/*
|
|
||||||
Input to cgo -godefs. See README.md
|
|
||||||
*/
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
/*
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <sys/sockio.h>
|
|
||||||
#include <sys/stropts.h>
|
|
||||||
|
|
||||||
// Many illumos distributions ship a 3rd party tun/tap driver
|
|
||||||
// from https://github.com/kaizawa/tuntap
|
|
||||||
// It supports a pair of IOCTLs defined at
|
|
||||||
// https://github.com/kaizawa/tuntap/blob/master/if_tun.h#L91-L93
|
|
||||||
#define TUNNEWPPA (('T'<<16) | 0x0001)
|
|
||||||
#define TUNSETPPA (('T'<<16) | 0x0002)
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
const (
|
|
||||||
TUNNEWPPA = C.TUNNEWPPA
|
|
||||||
TUNSETPPA = C.TUNSETPPA
|
|
||||||
|
|
||||||
// sys/stropts.h:
|
|
||||||
I_STR = C.I_STR
|
|
||||||
I_POP = C.I_POP
|
|
||||||
I_PUSH = C.I_PUSH
|
|
||||||
I_LINK = C.I_LINK
|
|
||||||
I_UNLINK = C.I_UNLINK
|
|
||||||
I_PLINK = C.I_PLINK
|
|
||||||
I_PUNLINK = C.I_PUNLINK
|
|
||||||
|
|
||||||
// sys/sockio.h:
|
|
||||||
IF_UNITSEL = C.IF_UNITSEL
|
|
||||||
)
|
|
||||||
|
|
||||||
type strbuf C.struct_strbuf
|
|
||||||
|
|
||||||
type Strioctl C.struct_strioctl
|
|
||||||
|
|
||||||
type Lifreq C.struct_lifreq
|
|
||||||
@@ -39,8 +39,10 @@ package unix
|
|||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
|
#include <sys/stropts.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -80,6 +82,12 @@ struct goIovec {
|
|||||||
size_t iov_len;
|
size_t iov_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Solaris and the major illumos distributions ship a 3rd party tun/tap driver
|
||||||
|
// from https://github.com/kaizawa/tuntap
|
||||||
|
// It supports a pair of IOCTLs defined at
|
||||||
|
// https://github.com/kaizawa/tuntap/blob/master/if_tun.h#L91-L93
|
||||||
|
#define TUNNEWPPA (('T'<<16) | 0x0001)
|
||||||
|
#define TUNSETPPA (('T'<<16) | 0x0002)
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
@@ -306,3 +314,28 @@ const (
|
|||||||
MOUNTEDOVER = C.MOUNTEDOVER
|
MOUNTEDOVER = C.MOUNTEDOVER
|
||||||
FILE_EXCEPTION = C.FILE_EXCEPTION
|
FILE_EXCEPTION = C.FILE_EXCEPTION
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// STREAMS and Tun
|
||||||
|
|
||||||
|
const (
|
||||||
|
TUNNEWPPA = C.TUNNEWPPA
|
||||||
|
TUNSETPPA = C.TUNSETPPA
|
||||||
|
|
||||||
|
// sys/stropts.h:
|
||||||
|
I_STR = C.I_STR
|
||||||
|
I_POP = C.I_POP
|
||||||
|
I_PUSH = C.I_PUSH
|
||||||
|
I_LINK = C.I_LINK
|
||||||
|
I_UNLINK = C.I_UNLINK
|
||||||
|
I_PLINK = C.I_PLINK
|
||||||
|
I_PUNLINK = C.I_PUNLINK
|
||||||
|
|
||||||
|
// sys/sockio.h:
|
||||||
|
IF_UNITSEL = C.IF_UNITSEL
|
||||||
|
)
|
||||||
|
|
||||||
|
type strbuf C.struct_strbuf
|
||||||
|
|
||||||
|
type Strioctl C.struct_strioctl
|
||||||
|
|
||||||
|
type Lifreq C.struct_lifreq
|
||||||
|
|||||||
@@ -15,25 +15,19 @@ import (
|
|||||||
//go:cgo_import_dynamic libc_writev writev "libc.so"
|
//go:cgo_import_dynamic libc_writev writev "libc.so"
|
||||||
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
|
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
|
||||||
//go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so"
|
//go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so"
|
||||||
//go:cgo_import_dynamic libc_putmsg putmsg "libc.so"
|
|
||||||
//go:cgo_import_dynamic libc_getmsg getmsg "libc.so"
|
|
||||||
|
|
||||||
//go:linkname procreadv libc_readv
|
//go:linkname procreadv libc_readv
|
||||||
//go:linkname procpreadv libc_preadv
|
//go:linkname procpreadv libc_preadv
|
||||||
//go:linkname procwritev libc_writev
|
//go:linkname procwritev libc_writev
|
||||||
//go:linkname procpwritev libc_pwritev
|
//go:linkname procpwritev libc_pwritev
|
||||||
//go:linkname procaccept4 libc_accept4
|
//go:linkname procaccept4 libc_accept4
|
||||||
//go:linkname procputmsg libc_putmsg
|
|
||||||
//go:linkname procgetmsg libc_getmsg
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
procreadv,
|
procreadv,
|
||||||
procpreadv,
|
procpreadv,
|
||||||
procwritev,
|
procwritev,
|
||||||
procpwritev,
|
procpwritev,
|
||||||
procaccept4,
|
procaccept4 syscallFunc
|
||||||
procputmsg,
|
|
||||||
procgetmsg syscallFunc
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
@@ -106,23 +100,3 @@ func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int,
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
||||||
|
|
||||||
func putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error) {
|
|
||||||
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procputmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(flags), 0, 0)
|
|
||||||
if e1 != 0 {
|
|
||||||
err = e1
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
||||||
|
|
||||||
func getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error) {
|
|
||||||
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(unsafe.Pointer(flags)), 0, 0)
|
|
||||||
if e1 != 0 {
|
|
||||||
err = e1
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -147,6 +147,8 @@ import (
|
|||||||
//go:cgo_import_dynamic libc_port_dissociate port_dissociate "libc.so"
|
//go:cgo_import_dynamic libc_port_dissociate port_dissociate "libc.so"
|
||||||
//go:cgo_import_dynamic libc_port_get port_get "libc.so"
|
//go:cgo_import_dynamic libc_port_get port_get "libc.so"
|
||||||
//go:cgo_import_dynamic libc_port_getn port_getn "libc.so"
|
//go:cgo_import_dynamic libc_port_getn port_getn "libc.so"
|
||||||
|
//go:cgo_import_dynamic libc_putmsg putmsg "libc.so"
|
||||||
|
//go:cgo_import_dynamic libc_getmsg getmsg "libc.so"
|
||||||
|
|
||||||
//go:linkname procpipe libc_pipe
|
//go:linkname procpipe libc_pipe
|
||||||
//go:linkname procpipe2 libc_pipe2
|
//go:linkname procpipe2 libc_pipe2
|
||||||
@@ -284,6 +286,8 @@ import (
|
|||||||
//go:linkname procport_dissociate libc_port_dissociate
|
//go:linkname procport_dissociate libc_port_dissociate
|
||||||
//go:linkname procport_get libc_port_get
|
//go:linkname procport_get libc_port_get
|
||||||
//go:linkname procport_getn libc_port_getn
|
//go:linkname procport_getn libc_port_getn
|
||||||
|
//go:linkname procputmsg libc_putmsg
|
||||||
|
//go:linkname procgetmsg libc_getmsg
|
||||||
|
|
||||||
var (
|
var (
|
||||||
procpipe,
|
procpipe,
|
||||||
@@ -421,7 +425,9 @@ var (
|
|||||||
procport_associate,
|
procport_associate,
|
||||||
procport_dissociate,
|
procport_dissociate,
|
||||||
procport_get,
|
procport_get,
|
||||||
procport_getn syscallFunc
|
procport_getn,
|
||||||
|
procputmsg,
|
||||||
|
procgetmsg syscallFunc
|
||||||
)
|
)
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
@@ -2065,3 +2071,23 @@ func port_getn(port int, pe *portEvent, max uint32, nget *uint32, timeout *Times
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error) {
|
||||||
|
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procputmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(flags), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error) {
|
||||||
|
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(unsafe.Pointer(flags)), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = e1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
// cgo -godefs types_illumos.go | go run mkpost.go
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
//go:build amd64 && illumos
|
|
||||||
// +build amd64,illumos
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
TUNNEWPPA = 0x540001
|
|
||||||
TUNSETPPA = 0x540002
|
|
||||||
|
|
||||||
I_STR = 0x5308
|
|
||||||
I_POP = 0x5303
|
|
||||||
I_PUSH = 0x5302
|
|
||||||
I_LINK = 0x530c
|
|
||||||
I_UNLINK = 0x530d
|
|
||||||
I_PLINK = 0x5316
|
|
||||||
I_PUNLINK = 0x5317
|
|
||||||
|
|
||||||
IF_UNITSEL = -0x7ffb8cca
|
|
||||||
)
|
|
||||||
|
|
||||||
type strbuf struct {
|
|
||||||
Maxlen int32
|
|
||||||
Len int32
|
|
||||||
Buf *int8
|
|
||||||
}
|
|
||||||
|
|
||||||
type Strioctl struct {
|
|
||||||
Cmd int32
|
|
||||||
Timout int32
|
|
||||||
Len int32
|
|
||||||
Dp *int8
|
|
||||||
}
|
|
||||||
|
|
||||||
type Lifreq struct {
|
|
||||||
Name [32]int8
|
|
||||||
Lifru1 [4]byte
|
|
||||||
Type uint32
|
|
||||||
Lifru [336]byte
|
|
||||||
}
|
|
||||||
@@ -480,3 +480,38 @@ const (
|
|||||||
MOUNTEDOVER = 0x40000000
|
MOUNTEDOVER = 0x40000000
|
||||||
FILE_EXCEPTION = 0x60000070
|
FILE_EXCEPTION = 0x60000070
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
TUNNEWPPA = 0x540001
|
||||||
|
TUNSETPPA = 0x540002
|
||||||
|
|
||||||
|
I_STR = 0x5308
|
||||||
|
I_POP = 0x5303
|
||||||
|
I_PUSH = 0x5302
|
||||||
|
I_LINK = 0x530c
|
||||||
|
I_UNLINK = 0x530d
|
||||||
|
I_PLINK = 0x5316
|
||||||
|
I_PUNLINK = 0x5317
|
||||||
|
|
||||||
|
IF_UNITSEL = -0x7ffb8cca
|
||||||
|
)
|
||||||
|
|
||||||
|
type strbuf struct {
|
||||||
|
Maxlen int32
|
||||||
|
Len int32
|
||||||
|
Buf *int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type Strioctl struct {
|
||||||
|
Cmd int32
|
||||||
|
Timout int32
|
||||||
|
Len int32
|
||||||
|
Dp *int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type Lifreq struct {
|
||||||
|
Name [32]int8
|
||||||
|
Lifru1 [4]byte
|
||||||
|
Type uint32
|
||||||
|
Lifru [336]byte
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user