Skip to content

Commit 493a077

Browse files
committed
syscall: revise for go1.12
Update #3
1 parent 91b1445 commit 493a077

22 files changed

+1519
-338
lines changed

gosrc/1.11.5/syscall/bpf_darwin.go

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
// Copyright 2018 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Berkeley packet filter for Darwin
6+
7+
package syscall
8+
9+
import (
10+
"unsafe"
11+
)
12+
13+
// Deprecated: Use golang.org/x/net/bpf instead.
14+
func BpfStmt(code, k int) *BpfInsn {
15+
return &BpfInsn{Code: uint16(code), K: uint32(k)}
16+
}
17+
18+
// Deprecated: Use golang.org/x/net/bpf instead.
19+
func BpfJump(code, k, jt, jf int) *BpfInsn {
20+
return &BpfInsn{Code: uint16(code), Jt: uint8(jt), Jf: uint8(jf), K: uint32(k)}
21+
}
22+
23+
// Deprecated: Use golang.org/x/net/bpf instead.
24+
func BpfBuflen(fd int) (int, error) {
25+
var l int
26+
err := ioctlPtr(fd, BIOCGBLEN, unsafe.Pointer(&l))
27+
if err != nil {
28+
return 0, err
29+
}
30+
return l, nil
31+
}
32+
33+
// Deprecated: Use golang.org/x/net/bpf instead.
34+
func SetBpfBuflen(fd, l int) (int, error) {
35+
err := ioctlPtr(fd, BIOCSBLEN, unsafe.Pointer(&l))
36+
if err != nil {
37+
return 0, err
38+
}
39+
return l, nil
40+
}
41+
42+
// Deprecated: Use golang.org/x/net/bpf instead.
43+
func BpfDatalink(fd int) (int, error) {
44+
var t int
45+
err := ioctlPtr(fd, BIOCGDLT, unsafe.Pointer(&t))
46+
if err != nil {
47+
return 0, err
48+
}
49+
return t, nil
50+
}
51+
52+
// Deprecated: Use golang.org/x/net/bpf instead.
53+
func SetBpfDatalink(fd, t int) (int, error) {
54+
err := ioctlPtr(fd, BIOCSDLT, unsafe.Pointer(&t))
55+
if err != nil {
56+
return 0, err
57+
}
58+
return t, nil
59+
}
60+
61+
// Deprecated: Use golang.org/x/net/bpf instead.
62+
func SetBpfPromisc(fd, m int) error {
63+
err := ioctlPtr(fd, BIOCPROMISC, unsafe.Pointer(&m))
64+
if err != nil {
65+
return err
66+
}
67+
return nil
68+
}
69+
70+
// Deprecated: Use golang.org/x/net/bpf instead.
71+
func FlushBpf(fd int) error {
72+
err := ioctlPtr(fd, BIOCFLUSH, nil)
73+
if err != nil {
74+
return err
75+
}
76+
return nil
77+
}
78+
79+
type ivalue struct {
80+
name [IFNAMSIZ]byte
81+
value int16
82+
}
83+
84+
// Deprecated: Use golang.org/x/net/bpf instead.
85+
func BpfInterface(fd int, name string) (string, error) {
86+
var iv ivalue
87+
err := ioctlPtr(fd, BIOCGETIF, unsafe.Pointer(&iv))
88+
if err != nil {
89+
return "", err
90+
}
91+
return name, nil
92+
}
93+
94+
// Deprecated: Use golang.org/x/net/bpf instead.
95+
func SetBpfInterface(fd int, name string) error {
96+
var iv ivalue
97+
copy(iv.name[:], []byte(name))
98+
err := ioctlPtr(fd, BIOCSETIF, unsafe.Pointer(&iv))
99+
if err != nil {
100+
return err
101+
}
102+
return nil
103+
}
104+
105+
// Deprecated: Use golang.org/x/net/bpf instead.
106+
func BpfTimeout(fd int) (*Timeval, error) {
107+
var tv Timeval
108+
err := ioctlPtr(fd, BIOCGRTIMEOUT, unsafe.Pointer(&tv))
109+
if err != nil {
110+
return nil, err
111+
}
112+
return &tv, nil
113+
}
114+
115+
// Deprecated: Use golang.org/x/net/bpf instead.
116+
func SetBpfTimeout(fd int, tv *Timeval) error {
117+
err := ioctlPtr(fd, BIOCSRTIMEOUT, unsafe.Pointer(tv))
118+
if err != nil {
119+
return err
120+
}
121+
return nil
122+
}
123+
124+
// Deprecated: Use golang.org/x/net/bpf instead.
125+
func BpfStats(fd int) (*BpfStat, error) {
126+
var s BpfStat
127+
err := ioctlPtr(fd, BIOCGSTATS, unsafe.Pointer(&s))
128+
if err != nil {
129+
return nil, err
130+
}
131+
return &s, nil
132+
}
133+
134+
// Deprecated: Use golang.org/x/net/bpf instead.
135+
func SetBpfImmediate(fd, m int) error {
136+
err := ioctlPtr(fd, BIOCIMMEDIATE, unsafe.Pointer(&m))
137+
if err != nil {
138+
return err
139+
}
140+
return nil
141+
}
142+
143+
// Deprecated: Use golang.org/x/net/bpf instead.
144+
func SetBpf(fd int, i []BpfInsn) error {
145+
var p BpfProgram
146+
p.Len = uint32(len(i))
147+
p.Insns = (*BpfInsn)(unsafe.Pointer(&i[0]))
148+
err := ioctlPtr(fd, BIOCSETF, unsafe.Pointer(&p))
149+
if err != nil {
150+
return err
151+
}
152+
return nil
153+
}
154+
155+
// Deprecated: Use golang.org/x/net/bpf instead.
156+
func CheckBpfVersion(fd int) error {
157+
var v BpfVersion
158+
err := ioctlPtr(fd, BIOCVERSION, unsafe.Pointer(&v))
159+
if err != nil {
160+
return err
161+
}
162+
if v.Major != BPF_MAJOR_VERSION || v.Minor != BPF_MINOR_VERSION {
163+
return EINVAL
164+
}
165+
return nil
166+
}
167+
168+
// Deprecated: Use golang.org/x/net/bpf instead.
169+
func BpfHeadercmpl(fd int) (int, error) {
170+
var f int
171+
err := ioctlPtr(fd, BIOCGHDRCMPLT, unsafe.Pointer(&f))
172+
if err != nil {
173+
return 0, err
174+
}
175+
return f, nil
176+
}
177+
178+
// Deprecated: Use golang.org/x/net/bpf instead.
179+
func SetBpfHeadercmpl(fd, f int) error {
180+
err := ioctlPtr(fd, BIOCSHDRCMPLT, unsafe.Pointer(&f))
181+
if err != nil {
182+
return err
183+
}
184+
return nil
185+
}

gosrc/1.11.5/syscall/dirent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

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

77
package syscall
88

gosrc/1.11.5/syscall/exec_linux.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ type SysProcIDMap struct {
2020
}
2121

2222
type SysProcAttr struct {
23-
Chroot string // Chroot.
24-
Credential *Credential // Credential.
25-
Ptrace bool // Enable tracing.
23+
Chroot string // Chroot.
24+
Credential *Credential // Credential.
25+
// Ptrace tells the child to call ptrace(PTRACE_TRACEME).
26+
// Call runtime.LockOSThread before starting a process with this set,
27+
// and don't call UnlockOSThread until done with PtraceSyscall calls.
28+
Ptrace bool
2629
Setsid bool // Create session.
2730
Setpgid bool // Set process group ID to Pgid, or, if Pgid == 0, to new pid.
2831
Setctty bool // Set controlling terminal to fd Ctty (only meaningful if Setsid is set)

gosrc/1.11.5/syscall/flock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build linux darwin freebsd openbsd netbsd dragonfly
1+
// +build linux freebsd openbsd netbsd dragonfly
22

33
// Copyright 2014 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

gosrc/1.11.5/syscall/forkpipe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build darwin dragonfly solaris
5+
// +build aix darwin dragonfly solaris
66

77
package syscall
88

0 commit comments

Comments
 (0)