Skip to content

Commit

Permalink
syscall: revise for go1.12
Browse files Browse the repository at this point in the history
Update #3
  • Loading branch information
changkun committed Jan 27, 2019
1 parent 91b1445 commit 493a077
Show file tree
Hide file tree
Showing 22 changed files with 1,519 additions and 338 deletions.
185 changes: 185 additions & 0 deletions gosrc/1.11.5/syscall/bpf_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
// Copyright 2018 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.

// Berkeley packet filter for Darwin

package syscall

import (
"unsafe"
)

// Deprecated: Use golang.org/x/net/bpf instead.
func BpfStmt(code, k int) *BpfInsn {
return &BpfInsn{Code: uint16(code), K: uint32(k)}
}

// Deprecated: Use golang.org/x/net/bpf instead.
func BpfJump(code, k, jt, jf int) *BpfInsn {
return &BpfInsn{Code: uint16(code), Jt: uint8(jt), Jf: uint8(jf), K: uint32(k)}
}

// Deprecated: Use golang.org/x/net/bpf instead.
func BpfBuflen(fd int) (int, error) {
var l int
err := ioctlPtr(fd, BIOCGBLEN, unsafe.Pointer(&l))
if err != nil {
return 0, err
}
return l, nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func SetBpfBuflen(fd, l int) (int, error) {
err := ioctlPtr(fd, BIOCSBLEN, unsafe.Pointer(&l))
if err != nil {
return 0, err
}
return l, nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func BpfDatalink(fd int) (int, error) {
var t int
err := ioctlPtr(fd, BIOCGDLT, unsafe.Pointer(&t))
if err != nil {
return 0, err
}
return t, nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func SetBpfDatalink(fd, t int) (int, error) {
err := ioctlPtr(fd, BIOCSDLT, unsafe.Pointer(&t))
if err != nil {
return 0, err
}
return t, nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func SetBpfPromisc(fd, m int) error {
err := ioctlPtr(fd, BIOCPROMISC, unsafe.Pointer(&m))
if err != nil {
return err
}
return nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func FlushBpf(fd int) error {
err := ioctlPtr(fd, BIOCFLUSH, nil)
if err != nil {
return err
}
return nil
}

type ivalue struct {
name [IFNAMSIZ]byte
value int16
}

// Deprecated: Use golang.org/x/net/bpf instead.
func BpfInterface(fd int, name string) (string, error) {
var iv ivalue
err := ioctlPtr(fd, BIOCGETIF, unsafe.Pointer(&iv))
if err != nil {
return "", err
}
return name, nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func SetBpfInterface(fd int, name string) error {
var iv ivalue
copy(iv.name[:], []byte(name))
err := ioctlPtr(fd, BIOCSETIF, unsafe.Pointer(&iv))
if err != nil {
return err
}
return nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func BpfTimeout(fd int) (*Timeval, error) {
var tv Timeval
err := ioctlPtr(fd, BIOCGRTIMEOUT, unsafe.Pointer(&tv))
if err != nil {
return nil, err
}
return &tv, nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func SetBpfTimeout(fd int, tv *Timeval) error {
err := ioctlPtr(fd, BIOCSRTIMEOUT, unsafe.Pointer(tv))
if err != nil {
return err
}
return nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func BpfStats(fd int) (*BpfStat, error) {
var s BpfStat
err := ioctlPtr(fd, BIOCGSTATS, unsafe.Pointer(&s))
if err != nil {
return nil, err
}
return &s, nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func SetBpfImmediate(fd, m int) error {
err := ioctlPtr(fd, BIOCIMMEDIATE, unsafe.Pointer(&m))
if err != nil {
return err
}
return nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func SetBpf(fd int, i []BpfInsn) error {
var p BpfProgram
p.Len = uint32(len(i))
p.Insns = (*BpfInsn)(unsafe.Pointer(&i[0]))
err := ioctlPtr(fd, BIOCSETF, unsafe.Pointer(&p))
if err != nil {
return err
}
return nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func CheckBpfVersion(fd int) error {
var v BpfVersion
err := ioctlPtr(fd, BIOCVERSION, unsafe.Pointer(&v))
if err != nil {
return err
}
if v.Major != BPF_MAJOR_VERSION || v.Minor != BPF_MINOR_VERSION {
return EINVAL
}
return nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func BpfHeadercmpl(fd int) (int, error) {
var f int
err := ioctlPtr(fd, BIOCGHDRCMPLT, unsafe.Pointer(&f))
if err != nil {
return 0, err
}
return f, nil
}

// Deprecated: Use golang.org/x/net/bpf instead.
func SetBpfHeadercmpl(fd, f int) error {
err := ioctlPtr(fd, BIOCSHDRCMPLT, unsafe.Pointer(&f))
if err != nil {
return err
}
return nil
}
2 changes: 1 addition & 1 deletion gosrc/1.11.5/syscall/dirent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris
// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris

package syscall

Expand Down
9 changes: 6 additions & 3 deletions gosrc/1.11.5/syscall/exec_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ type SysProcIDMap struct {
}

type SysProcAttr struct {
Chroot string // Chroot.
Credential *Credential // Credential.
Ptrace bool // Enable tracing.
Chroot string // Chroot.
Credential *Credential // Credential.
// Ptrace tells the child to call ptrace(PTRACE_TRACEME).
// Call runtime.LockOSThread before starting a process with this set,
// and don't call UnlockOSThread until done with PtraceSyscall calls.
Ptrace bool
Setsid bool // Create session.
Setpgid bool // Set process group ID to Pgid, or, if Pgid == 0, to new pid.
Setctty bool // Set controlling terminal to fd Ctty (only meaningful if Setsid is set)
Expand Down
2 changes: 1 addition & 1 deletion gosrc/1.11.5/syscall/flock.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build linux darwin freebsd openbsd netbsd dragonfly
// +build linux freebsd openbsd netbsd dragonfly

// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
2 changes: 1 addition & 1 deletion gosrc/1.11.5/syscall/forkpipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build darwin dragonfly solaris
// +build aix darwin dragonfly solaris

package syscall

Expand Down
Loading

0 comments on commit 493a077

Please sign in to comment.