Explorar el Código

Implement email alerting

Brendan Abolivier hace 7 años
padre
commit
c39d6de4b5
Firmado por: Brendan Abolivier <contact@brendanabolivier.com> ID clave GPG: 8EF1500759F70623
Se han modificado 100 ficheros con 9761 adiciones y 13 borrados
  1. 8
    2
      config.sample.yaml
  2. 18
    6
      src/metrics-alerting/alert/alert.go
  3. 48
    2
      src/metrics-alerting/alert/email.go
  4. 25
    1
      src/metrics-alerting/config/config.go
  5. 2
    2
      src/metrics-alerting/main.go
  6. 26
    0
      vendor/manifest
  7. 951
    0
      vendor/src/golang.org/x/crypto/ssh/terminal/terminal.go
  8. 350
    0
      vendor/src/golang.org/x/crypto/ssh/terminal/terminal_test.go
  9. 116
    0
      vendor/src/golang.org/x/crypto/ssh/terminal/util.go
  10. 12
    0
      vendor/src/golang.org/x/crypto/ssh/terminal/util_bsd.go
  11. 10
    0
      vendor/src/golang.org/x/crypto/ssh/terminal/util_linux.go
  12. 58
    0
      vendor/src/golang.org/x/crypto/ssh/terminal/util_plan9.go
  13. 128
    0
      vendor/src/golang.org/x/crypto/ssh/terminal/util_solaris.go
  14. 102
    0
      vendor/src/golang.org/x/crypto/ssh/terminal/util_windows.go
  15. 173
    0
      vendor/src/golang.org/x/sys/unix/README.md
  16. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_darwin_386.s
  17. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_darwin_amd64.s
  18. 30
    0
      vendor/src/golang.org/x/sys/unix/asm_darwin_arm.s
  19. 30
    0
      vendor/src/golang.org/x/sys/unix/asm_darwin_arm64.s
  20. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_dragonfly_amd64.s
  21. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_freebsd_386.s
  22. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_freebsd_amd64.s
  23. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_freebsd_arm.s
  24. 35
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_386.s
  25. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_amd64.s
  26. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_arm.s
  27. 24
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_arm64.s
  28. 28
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_mips64x.s
  29. 31
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_mipsx.s
  30. 28
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_ppc64x.s
  31. 28
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_s390x.s
  32. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_netbsd_386.s
  33. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_netbsd_amd64.s
  34. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_netbsd_arm.s
  35. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_openbsd_386.s
  36. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_openbsd_amd64.s
  37. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_openbsd_arm.s
  38. 17
    0
      vendor/src/golang.org/x/sys/unix/asm_solaris_amd64.s
  39. 35
    0
      vendor/src/golang.org/x/sys/unix/bluetooth_linux.go
  40. 195
    0
      vendor/src/golang.org/x/sys/unix/cap_freebsd.go
  41. 13
    0
      vendor/src/golang.org/x/sys/unix/constants.go
  42. 136
    0
      vendor/src/golang.org/x/sys/unix/creds_test.go
  43. 24
    0
      vendor/src/golang.org/x/sys/unix/dev_darwin.go
  44. 51
    0
      vendor/src/golang.org/x/sys/unix/dev_darwin_test.go
  45. 30
    0
      vendor/src/golang.org/x/sys/unix/dev_dragonfly.go
  46. 50
    0
      vendor/src/golang.org/x/sys/unix/dev_dragonfly_test.go
  47. 30
    0
      vendor/src/golang.org/x/sys/unix/dev_freebsd.go
  48. 42
    0
      vendor/src/golang.org/x/sys/unix/dev_linux.go
  49. 53
    0
      vendor/src/golang.org/x/sys/unix/dev_linux_test.go
  50. 29
    0
      vendor/src/golang.org/x/sys/unix/dev_netbsd.go
  51. 52
    0
      vendor/src/golang.org/x/sys/unix/dev_netbsd_test.go
  52. 29
    0
      vendor/src/golang.org/x/sys/unix/dev_openbsd.go
  53. 54
    0
      vendor/src/golang.org/x/sys/unix/dev_openbsd_test.go
  54. 51
    0
      vendor/src/golang.org/x/sys/unix/dev_solaris_test.go
  55. 102
    0
      vendor/src/golang.org/x/sys/unix/dirent.go
  56. 9
    0
      vendor/src/golang.org/x/sys/unix/endian_big.go
  57. 9
    0
      vendor/src/golang.org/x/sys/unix/endian_little.go
  58. 27
    0
      vendor/src/golang.org/x/sys/unix/env_unix.go
  59. 14
    0
      vendor/src/golang.org/x/sys/unix/env_unset.go
  60. 227
    0
      vendor/src/golang.org/x/sys/unix/errors_freebsd_386.go
  61. 227
    0
      vendor/src/golang.org/x/sys/unix/errors_freebsd_amd64.go
  62. 226
    0
      vendor/src/golang.org/x/sys/unix/errors_freebsd_arm.go
  63. 9
    0
      vendor/src/golang.org/x/sys/unix/export_test.go
  64. 22
    0
      vendor/src/golang.org/x/sys/unix/flock.go
  65. 13
    0
      vendor/src/golang.org/x/sys/unix/flock_linux_32bit.go
  66. 46
    0
      vendor/src/golang.org/x/sys/unix/gccgo.go
  67. 41
    0
      vendor/src/golang.org/x/sys/unix/gccgo_c.c
  68. 20
    0
      vendor/src/golang.org/x/sys/unix/gccgo_linux_amd64.go
  69. 51
    0
      vendor/src/golang.org/x/sys/unix/linux/Dockerfile
  70. 482
    0
      vendor/src/golang.org/x/sys/unix/linux/mkall.go
  71. 85
    0
      vendor/src/golang.org/x/sys/unix/linux/mksysnum.pl
  72. 595
    0
      vendor/src/golang.org/x/sys/unix/linux/types.go
  73. 194
    0
      vendor/src/golang.org/x/sys/unix/mkall.sh
  74. 577
    0
      vendor/src/golang.org/x/sys/unix/mkerrors.sh
  75. 93
    0
      vendor/src/golang.org/x/sys/unix/mkpost.go
  76. 328
    0
      vendor/src/golang.org/x/sys/unix/mksyscall.pl
  77. 289
    0
      vendor/src/golang.org/x/sys/unix/mksyscall_solaris.pl
  78. 264
    0
      vendor/src/golang.org/x/sys/unix/mksysctl_openbsd.pl
  79. 39
    0
      vendor/src/golang.org/x/sys/unix/mksysnum_darwin.pl
  80. 50
    0
      vendor/src/golang.org/x/sys/unix/mksysnum_dragonfly.pl
  81. 50
    0
      vendor/src/golang.org/x/sys/unix/mksysnum_freebsd.pl
  82. 58
    0
      vendor/src/golang.org/x/sys/unix/mksysnum_netbsd.pl
  83. 50
    0
      vendor/src/golang.org/x/sys/unix/mksysnum_openbsd.pl
  84. 35
    0
      vendor/src/golang.org/x/sys/unix/mmap_unix_test.go
  85. 38
    0
      vendor/src/golang.org/x/sys/unix/openbsd_pledge.go
  86. 113
    0
      vendor/src/golang.org/x/sys/unix/openbsd_test.go
  87. 15
    0
      vendor/src/golang.org/x/sys/unix/pagesize_unix.go
  88. 30
    0
      vendor/src/golang.org/x/sys/unix/race.go
  89. 25
    0
      vendor/src/golang.org/x/sys/unix/race0.go
  90. 36
    0
      vendor/src/golang.org/x/sys/unix/sockcmsg_linux.go
  91. 104
    0
      vendor/src/golang.org/x/sys/unix/sockcmsg_unix.go
  92. 26
    0
      vendor/src/golang.org/x/sys/unix/str.go
  93. 51
    0
      vendor/src/golang.org/x/sys/unix/syscall.go
  94. 653
    0
      vendor/src/golang.org/x/sys/unix/syscall_bsd.go
  95. 70
    0
      vendor/src/golang.org/x/sys/unix/syscall_bsd_test.go
  96. 612
    0
      vendor/src/golang.org/x/sys/unix/syscall_darwin.go
  97. 68
    0
      vendor/src/golang.org/x/sys/unix/syscall_darwin_386.go
  98. 68
    0
      vendor/src/golang.org/x/sys/unix/syscall_darwin_amd64.go
  99. 62
    0
      vendor/src/golang.org/x/sys/unix/syscall_darwin_arm.go
  100. 0
    0
      vendor/src/golang.org/x/sys/unix/syscall_darwin_arm64.go

+ 8
- 2
config.sample.yaml Ver fichero

@@ -1,3 +1,11 @@
1
+mail:
2
+    sender: foo@bar.baz
3
+    recipient: admin@bar.baz
4
+    smtp:
5
+        host: smtp.bar.baz
6
+        port: 465
7
+        username: foo@bar.baz
8
+        password: hackme
1 9
 warp10_exec: http://localhost/api/v0/exec
2 10
 token: READ_TOKEN
3 11
 scripts:
@@ -13,9 +21,7 @@ scripts:
13 21
             ] FETCH
14 22
             VALUES LIST-> DROP LIST-> DROP
15 23
             "
16
-        # bool | number
17 24
         type: number
18
-        # only required if type == number
19 25
         threshold: 50
20 26
         action: http
21 27
         target: http://localhost:9996/alert

+ 18
- 6
src/metrics-alerting/alert/alert.go Ver fichero

@@ -7,7 +7,11 @@ import (
7 7
 	"metrics-alerting/warp10"
8 8
 )
9 9
 
10
-func ProcessNumber(client warp10.Warp10Client, script config.Script) error {
10
+func ProcessNumber(
11
+	client warp10.Warp10Client,
12
+	script config.Script,
13
+	ms config.MailSettings,
14
+) error {
11 15
 	value, err := client.ReadNumber(script.Script)
12 16
 	if err != nil {
13 17
 		return err
@@ -18,10 +22,14 @@ func ProcessNumber(client warp10.Warp10Client, script config.Script) error {
18 22
 		return nil
19 23
 	}
20 24
 
21
-	return alert(script, value)
25
+	return alert(script, value, ms)
22 26
 }
23 27
 
24
-func ProcessBool(client warp10.Warp10Client, script config.Script) error {
28
+func ProcessBool(
29
+	client warp10.Warp10Client,
30
+	script config.Script,
31
+	ms config.MailSettings,
32
+) error {
25 33
 	value, err := client.ReadBool(script.Script)
26 34
 	if err != nil {
27 35
 		return err
@@ -31,15 +39,19 @@ func ProcessBool(client warp10.Warp10Client, script config.Script) error {
31 39
 		return nil
32 40
 	}
33 41
 
34
-	return alert(script, value)
42
+	return alert(script, value, ms)
35 43
 }
36 44
 
37
-func alert(script config.Script, result interface{}) error {
45
+func alert(
46
+	script config.Script,
47
+	result interface{},
48
+	ms config.MailSettings,
49
+) error {
38 50
 	switch script.Action {
39 51
 	case "http":
40 52
 		return alertHttp(script, result)
41 53
 	case "email":
42
-		return alertEmail(script, result)
54
+		return alertEmail(script, result, ms)
43 55
 	default:
44 56
 		return fmt.Errorf("invalid action type: %s", script.Action)
45 57
 	}

+ 48
- 2
src/metrics-alerting/alert/email.go Ver fichero

@@ -1,9 +1,55 @@
1 1
 package alert
2 2
 
3 3
 import (
4
+	"fmt"
5
+
4 6
 	"metrics-alerting/config"
7
+
8
+	"gopkg.in/gomail.v2"
5 9
 )
6 10
 
7
-func alertEmail(script config.Script, result interface{}) error {
8
-	return nil
11
+func alertEmail(
12
+	script config.Script,
13
+	result interface{},
14
+	ms config.MailSettings,
15
+) error {
16
+	formatNumber := `
17
+Script %s just exceeded its threshold of %f and now returns %f
18
+
19
+Script:
20
+
21
+%s
22
+	`
23
+
24
+	formatBool := `
25
+Test for script %s and returned false instead of true
26
+
27
+Script:
28
+
29
+%s
30
+	`
31
+
32
+	var body, subject string
33
+	switch script.Type {
34
+	case "number":
35
+		subject = fmt.Sprintf("Threshold exceeded for script %s", script.Key)
36
+		body = fmt.Sprintf(
37
+			formatNumber, script.Key, script.Threshold, result.(float64),
38
+			script.Script,
39
+		)
40
+	case "bool":
41
+		subject = fmt.Sprintf("Test for script %s failed", script.Key)
42
+		body = fmt.Sprintf(formatBool, script.Key, script.Script)
43
+	}
44
+
45
+	m := gomail.NewMessage()
46
+	m.SetHeader("From", ms.Sender)
47
+	m.SetHeader("To", ms.Recipient)
48
+	m.SetHeader("Subject", subject)
49
+	m.SetBody("text/plain", body)
50
+
51
+	d := gomail.NewDialer(
52
+		ms.SMTP.Host, ms.SMTP.Port, ms.SMTP.Username, ms.SMTP.Password,
53
+	)
54
+	return d.DialAndSend(m)
9 55
 }

+ 25
- 1
src/metrics-alerting/config/config.go Ver fichero

@@ -6,6 +6,26 @@ import (
6 6
 	"gopkg.in/yaml.v2"
7 7
 )
8 8
 
9
+type MailSettings struct {
10
+	// Sender of the alert emails
11
+	Sender string `yaml:"sender"`
12
+	// Recipient of the alert emails
13
+	Recipient string `yaml:"recipient"`
14
+	// Settings to connect to the mail server
15
+	SMTP SMTPSettings `yaml:"smtp"`
16
+}
17
+
18
+type SMTPSettings struct {
19
+	// Host of the mail server
20
+	Host string `yaml:"host"`
21
+	// Port of the mail server
22
+	Port int `yaml:"port"`
23
+	// Username used to authenticate on the mail server
24
+	Username string `yaml:"username"`
25
+	// Password used to authenticate on the mail server
26
+	Password string `yaml:"password"`
27
+}
28
+
9 29
 type Script struct {
10 30
 	// An identifying key for the script
11 31
 	Key string `yaml:"key"`
@@ -13,7 +33,8 @@ type Script struct {
13 33
 	Script string `yaml:"script"`
14 34
 	// The type of the value returned by the script
15 35
 	Type string `yaml:"type"`
16
-	// Value above which an action is required
36
+	// Value above which an action is required, only required if the type is
37
+	// "number"
17 38
 	Threshold float64 `yaml:"threshold,omitempty"`
18 39
 	// The action to take (either "http" or "email")
19 40
 	Action string `yaml:"action"`
@@ -22,6 +43,9 @@ type Script struct {
22 43
 }
23 44
 
24 45
 type Config struct {
46
+	// Settings to send email alerts, only required if the action of at least 1
47
+	// script is "email"
48
+	Mail MailSettings `yaml:"mail,omitempty"`
25 49
 	// Full URL to Warp10's /exec
26 50
 	Warp10Exec string `yaml:"warp10_exec"`
27 51
 	// Warp10 read token

+ 2
- 2
src/metrics-alerting/main.go Ver fichero

@@ -28,10 +28,10 @@ func main() {
28 28
 		var err error
29 29
 		switch script.Type {
30 30
 		case "number":
31
-			err = alert.ProcessNumber(client, script)
31
+			err = alert.ProcessNumber(client, script, cfg.Mail)
32 32
 			break
33 33
 		case "bool":
34
-			err = alert.ProcessBool(client, script)
34
+			err = alert.ProcessBool(client, script, cfg.Mail)
35 35
 			break
36 36
 		default:
37 37
 			err = fmt.Errorf("invalid return type: %s", script.Type)

+ 26
- 0
vendor/manifest Ver fichero

@@ -2,6 +2,32 @@
2 2
 	"version": 0,
3 3
 	"dependencies": [
4 4
 		{
5
+			"importpath": "github.com/sirupsen/logrus",
6
+			"repository": "https://github.com/sirupsen/logrus",
7
+			"revision": "95cd2b9c79aa5e72ab0bc69b7ccc2be15bf850f6",
8
+			"branch": "master"
9
+		},
10
+		{
11
+			"importpath": "golang.org/x/crypto/ssh/terminal",
12
+			"repository": "https://go.googlesource.com/crypto",
13
+			"revision": "9f005a07e0d31d45e6656d241bb5c0f2efd4bc94",
14
+			"branch": "master",
15
+			"path": "/ssh/terminal"
16
+		},
17
+		{
18
+			"importpath": "golang.org/x/sys/unix",
19
+			"repository": "https://go.googlesource.com/sys",
20
+			"revision": "328643532ee3c60c099171d4ce2cad0ca0354ca9",
21
+			"branch": "master",
22
+			"path": "/unix"
23
+		},
24
+		{
25
+			"importpath": "gopkg.in/gomail.v2",
26
+			"repository": "https://gopkg.in/gomail.v2",
27
+			"revision": "81ebce5c23dfd25c6c67194b37d3dd3f338c98b1",
28
+			"branch": "v2"
29
+		},
30
+		{
5 31
 			"importpath": "gopkg.in/yaml.v2",
6 32
 			"repository": "https://gopkg.in/yaml.v2",
7 33
 			"revision": "287cf08546ab5e7e37d55a84f7ed3fd1db036de5",

+ 951
- 0
vendor/src/golang.org/x/crypto/ssh/terminal/terminal.go Ver fichero

@@ -0,0 +1,951 @@
1
+// Copyright 2011 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
+package terminal
6
+
7
+import (
8
+	"bytes"
9
+	"io"
10
+	"sync"
11
+	"unicode/utf8"
12
+)
13
+
14
+// EscapeCodes contains escape sequences that can be written to the terminal in
15
+// order to achieve different styles of text.
16
+type EscapeCodes struct {
17
+	// Foreground colors
18
+	Black, Red, Green, Yellow, Blue, Magenta, Cyan, White []byte
19
+
20
+	// Reset all attributes
21
+	Reset []byte
22
+}
23
+
24
+var vt100EscapeCodes = EscapeCodes{
25
+	Black:   []byte{keyEscape, '[', '3', '0', 'm'},
26
+	Red:     []byte{keyEscape, '[', '3', '1', 'm'},
27
+	Green:   []byte{keyEscape, '[', '3', '2', 'm'},
28
+	Yellow:  []byte{keyEscape, '[', '3', '3', 'm'},
29
+	Blue:    []byte{keyEscape, '[', '3', '4', 'm'},
30
+	Magenta: []byte{keyEscape, '[', '3', '5', 'm'},
31
+	Cyan:    []byte{keyEscape, '[', '3', '6', 'm'},
32
+	White:   []byte{keyEscape, '[', '3', '7', 'm'},
33
+
34
+	Reset: []byte{keyEscape, '[', '0', 'm'},
35
+}
36
+
37
+// Terminal contains the state for running a VT100 terminal that is capable of
38
+// reading lines of input.
39
+type Terminal struct {
40
+	// AutoCompleteCallback, if non-null, is called for each keypress with
41
+	// the full input line and the current position of the cursor (in
42
+	// bytes, as an index into |line|). If it returns ok=false, the key
43
+	// press is processed normally. Otherwise it returns a replacement line
44
+	// and the new cursor position.
45
+	AutoCompleteCallback func(line string, pos int, key rune) (newLine string, newPos int, ok bool)
46
+
47
+	// Escape contains a pointer to the escape codes for this terminal.
48
+	// It's always a valid pointer, although the escape codes themselves
49
+	// may be empty if the terminal doesn't support them.
50
+	Escape *EscapeCodes
51
+
52
+	// lock protects the terminal and the state in this object from
53
+	// concurrent processing of a key press and a Write() call.
54
+	lock sync.Mutex
55
+
56
+	c      io.ReadWriter
57
+	prompt []rune
58
+
59
+	// line is the current line being entered.
60
+	line []rune
61
+	// pos is the logical position of the cursor in line
62
+	pos int
63
+	// echo is true if local echo is enabled
64
+	echo bool
65
+	// pasteActive is true iff there is a bracketed paste operation in
66
+	// progress.
67
+	pasteActive bool
68
+
69
+	// cursorX contains the current X value of the cursor where the left
70
+	// edge is 0. cursorY contains the row number where the first row of
71
+	// the current line is 0.
72
+	cursorX, cursorY int
73
+	// maxLine is the greatest value of cursorY so far.
74
+	maxLine int
75
+
76
+	termWidth, termHeight int
77
+
78
+	// outBuf contains the terminal data to be sent.
79
+	outBuf []byte
80
+	// remainder contains the remainder of any partial key sequences after
81
+	// a read. It aliases into inBuf.
82
+	remainder []byte
83
+	inBuf     [256]byte
84
+
85
+	// history contains previously entered commands so that they can be
86
+	// accessed with the up and down keys.
87
+	history stRingBuffer
88
+	// historyIndex stores the currently accessed history entry, where zero
89
+	// means the immediately previous entry.
90
+	historyIndex int
91
+	// When navigating up and down the history it's possible to return to
92
+	// the incomplete, initial line. That value is stored in
93
+	// historyPending.
94
+	historyPending string
95
+}
96
+
97
+// NewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is
98
+// a local terminal, that terminal must first have been put into raw mode.
99
+// prompt is a string that is written at the start of each input line (i.e.
100
+// "> ").
101
+func NewTerminal(c io.ReadWriter, prompt string) *Terminal {
102
+	return &Terminal{
103
+		Escape:       &vt100EscapeCodes,
104
+		c:            c,
105
+		prompt:       []rune(prompt),
106
+		termWidth:    80,
107
+		termHeight:   24,
108
+		echo:         true,
109
+		historyIndex: -1,
110
+	}
111
+}
112
+
113
+const (
114
+	keyCtrlD     = 4
115
+	keyCtrlU     = 21
116
+	keyEnter     = '\r'
117
+	keyEscape    = 27
118
+	keyBackspace = 127
119
+	keyUnknown   = 0xd800 /* UTF-16 surrogate area */ + iota
120
+	keyUp
121
+	keyDown
122
+	keyLeft
123
+	keyRight
124
+	keyAltLeft
125
+	keyAltRight
126
+	keyHome
127
+	keyEnd
128
+	keyDeleteWord
129
+	keyDeleteLine
130
+	keyClearScreen
131
+	keyPasteStart
132
+	keyPasteEnd
133
+)
134
+
135
+var (
136
+	crlf       = []byte{'\r', '\n'}
137
+	pasteStart = []byte{keyEscape, '[', '2', '0', '0', '~'}
138
+	pasteEnd   = []byte{keyEscape, '[', '2', '0', '1', '~'}
139
+)
140
+
141
+// bytesToKey tries to parse a key sequence from b. If successful, it returns
142
+// the key and the remainder of the input. Otherwise it returns utf8.RuneError.
143
+func bytesToKey(b []byte, pasteActive bool) (rune, []byte) {
144
+	if len(b) == 0 {
145
+		return utf8.RuneError, nil
146
+	}
147
+
148
+	if !pasteActive {
149
+		switch b[0] {
150
+		case 1: // ^A
151
+			return keyHome, b[1:]
152
+		case 5: // ^E
153
+			return keyEnd, b[1:]
154
+		case 8: // ^H
155
+			return keyBackspace, b[1:]
156
+		case 11: // ^K
157
+			return keyDeleteLine, b[1:]
158
+		case 12: // ^L
159
+			return keyClearScreen, b[1:]
160
+		case 23: // ^W
161
+			return keyDeleteWord, b[1:]
162
+		}
163
+	}
164
+
165
+	if b[0] != keyEscape {
166
+		if !utf8.FullRune(b) {
167
+			return utf8.RuneError, b
168
+		}
169
+		r, l := utf8.DecodeRune(b)
170
+		return r, b[l:]
171
+	}
172
+
173
+	if !pasteActive && len(b) >= 3 && b[0] == keyEscape && b[1] == '[' {
174
+		switch b[2] {
175
+		case 'A':
176
+			return keyUp, b[3:]
177
+		case 'B':
178
+			return keyDown, b[3:]
179
+		case 'C':
180
+			return keyRight, b[3:]
181
+		case 'D':
182
+			return keyLeft, b[3:]
183
+		case 'H':
184
+			return keyHome, b[3:]
185
+		case 'F':
186
+			return keyEnd, b[3:]
187
+		}
188
+	}
189
+
190
+	if !pasteActive && len(b) >= 6 && b[0] == keyEscape && b[1] == '[' && b[2] == '1' && b[3] == ';' && b[4] == '3' {
191
+		switch b[5] {
192
+		case 'C':
193
+			return keyAltRight, b[6:]
194
+		case 'D':
195
+			return keyAltLeft, b[6:]
196
+		}
197
+	}
198
+
199
+	if !pasteActive && len(b) >= 6 && bytes.Equal(b[:6], pasteStart) {
200
+		return keyPasteStart, b[6:]
201
+	}
202
+
203
+	if pasteActive && len(b) >= 6 && bytes.Equal(b[:6], pasteEnd) {
204
+		return keyPasteEnd, b[6:]
205
+	}
206
+
207
+	// If we get here then we have a key that we don't recognise, or a
208
+	// partial sequence. It's not clear how one should find the end of a
209
+	// sequence without knowing them all, but it seems that [a-zA-Z~] only
210
+	// appears at the end of a sequence.
211
+	for i, c := range b[0:] {
212
+		if c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '~' {
213
+			return keyUnknown, b[i+1:]
214
+		}
215
+	}
216
+
217
+	return utf8.RuneError, b
218
+}
219
+
220
+// queue appends data to the end of t.outBuf
221
+func (t *Terminal) queue(data []rune) {
222
+	t.outBuf = append(t.outBuf, []byte(string(data))...)
223
+}
224
+
225
+var eraseUnderCursor = []rune{' ', keyEscape, '[', 'D'}
226
+var space = []rune{' '}
227
+
228
+func isPrintable(key rune) bool {
229
+	isInSurrogateArea := key >= 0xd800 && key <= 0xdbff
230
+	return key >= 32 && !isInSurrogateArea
231
+}
232
+
233
+// moveCursorToPos appends data to t.outBuf which will move the cursor to the
234
+// given, logical position in the text.
235
+func (t *Terminal) moveCursorToPos(pos int) {
236
+	if !t.echo {
237
+		return
238
+	}
239
+
240
+	x := visualLength(t.prompt) + pos
241
+	y := x / t.termWidth
242
+	x = x % t.termWidth
243
+
244
+	up := 0
245
+	if y < t.cursorY {
246
+		up = t.cursorY - y
247
+	}
248
+
249
+	down := 0
250
+	if y > t.cursorY {
251
+		down = y - t.cursorY
252
+	}
253
+
254
+	left := 0
255
+	if x < t.cursorX {
256
+		left = t.cursorX - x
257
+	}
258
+
259
+	right := 0
260
+	if x > t.cursorX {
261
+		right = x - t.cursorX
262
+	}
263
+
264
+	t.cursorX = x
265
+	t.cursorY = y
266
+	t.move(up, down, left, right)
267
+}
268
+
269
+func (t *Terminal) move(up, down, left, right int) {
270
+	movement := make([]rune, 3*(up+down+left+right))
271
+	m := movement
272
+	for i := 0; i < up; i++ {
273
+		m[0] = keyEscape
274
+		m[1] = '['
275
+		m[2] = 'A'
276
+		m = m[3:]
277
+	}
278
+	for i := 0; i < down; i++ {
279
+		m[0] = keyEscape
280
+		m[1] = '['
281
+		m[2] = 'B'
282
+		m = m[3:]
283
+	}
284
+	for i := 0; i < left; i++ {
285
+		m[0] = keyEscape
286
+		m[1] = '['
287
+		m[2] = 'D'
288
+		m = m[3:]
289
+	}
290
+	for i := 0; i < right; i++ {
291
+		m[0] = keyEscape
292
+		m[1] = '['
293
+		m[2] = 'C'
294
+		m = m[3:]
295
+	}
296
+
297
+	t.queue(movement)
298
+}
299
+
300
+func (t *Terminal) clearLineToRight() {
301
+	op := []rune{keyEscape, '[', 'K'}
302
+	t.queue(op)
303
+}
304
+
305
+const maxLineLength = 4096
306
+
307
+func (t *Terminal) setLine(newLine []rune, newPos int) {
308
+	if t.echo {
309
+		t.moveCursorToPos(0)
310
+		t.writeLine(newLine)
311
+		for i := len(newLine); i < len(t.line); i++ {
312
+			t.writeLine(space)
313
+		}
314
+		t.moveCursorToPos(newPos)
315
+	}
316
+	t.line = newLine
317
+	t.pos = newPos
318
+}
319
+
320
+func (t *Terminal) advanceCursor(places int) {
321
+	t.cursorX += places
322
+	t.cursorY += t.cursorX / t.termWidth
323
+	if t.cursorY > t.maxLine {
324
+		t.maxLine = t.cursorY
325
+	}
326
+	t.cursorX = t.cursorX % t.termWidth
327
+
328
+	if places > 0 && t.cursorX == 0 {
329
+		// Normally terminals will advance the current position
330
+		// when writing a character. But that doesn't happen
331
+		// for the last character in a line. However, when
332
+		// writing a character (except a new line) that causes
333
+		// a line wrap, the position will be advanced two
334
+		// places.
335
+		//
336
+		// So, if we are stopping at the end of a line, we
337
+		// need to write a newline so that our cursor can be
338
+		// advanced to the next line.
339
+		t.outBuf = append(t.outBuf, '\r', '\n')
340
+	}
341
+}
342
+
343
+func (t *Terminal) eraseNPreviousChars(n int) {
344
+	if n == 0 {
345
+		return
346
+	}
347
+
348
+	if t.pos < n {
349
+		n = t.pos
350
+	}
351
+	t.pos -= n
352
+	t.moveCursorToPos(t.pos)
353
+
354
+	copy(t.line[t.pos:], t.line[n+t.pos:])
355
+	t.line = t.line[:len(t.line)-n]
356
+	if t.echo {
357
+		t.writeLine(t.line[t.pos:])
358
+		for i := 0; i < n; i++ {
359
+			t.queue(space)
360
+		}
361
+		t.advanceCursor(n)
362
+		t.moveCursorToPos(t.pos)
363
+	}
364
+}
365
+
366
+// countToLeftWord returns then number of characters from the cursor to the
367
+// start of the previous word.
368
+func (t *Terminal) countToLeftWord() int {
369
+	if t.pos == 0 {
370
+		return 0
371
+	}
372
+
373
+	pos := t.pos - 1
374
+	for pos > 0 {
375
+		if t.line[pos] != ' ' {
376
+			break
377
+		}
378
+		pos--
379
+	}
380
+	for pos > 0 {
381
+		if t.line[pos] == ' ' {
382
+			pos++
383
+			break
384
+		}
385
+		pos--
386
+	}
387
+
388
+	return t.pos - pos
389
+}
390
+
391
+// countToRightWord returns then number of characters from the cursor to the
392
+// start of the next word.
393
+func (t *Terminal) countToRightWord() int {
394
+	pos := t.pos
395
+	for pos < len(t.line) {
396
+		if t.line[pos] == ' ' {
397
+			break
398
+		}
399
+		pos++
400
+	}
401
+	for pos < len(t.line) {
402
+		if t.line[pos] != ' ' {
403
+			break
404
+		}
405
+		pos++
406
+	}
407
+	return pos - t.pos
408
+}
409
+
410
+// visualLength returns the number of visible glyphs in s.
411
+func visualLength(runes []rune) int {
412
+	inEscapeSeq := false
413
+	length := 0
414
+
415
+	for _, r := range runes {
416
+		switch {
417
+		case inEscapeSeq:
418
+			if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') {
419
+				inEscapeSeq = false
420
+			}
421
+		case r == '\x1b':
422
+			inEscapeSeq = true
423
+		default:
424
+			length++
425
+		}
426
+	}
427
+
428
+	return length
429
+}
430
+
431
+// handleKey processes the given key and, optionally, returns a line of text
432
+// that the user has entered.
433
+func (t *Terminal) handleKey(key rune) (line string, ok bool) {
434
+	if t.pasteActive && key != keyEnter {
435
+		t.addKeyToLine(key)
436
+		return
437
+	}
438
+
439
+	switch key {
440
+	case keyBackspace:
441
+		if t.pos == 0 {
442
+			return
443
+		}
444
+		t.eraseNPreviousChars(1)
445
+	case keyAltLeft:
446
+		// move left by a word.
447
+		t.pos -= t.countToLeftWord()
448
+		t.moveCursorToPos(t.pos)
449
+	case keyAltRight:
450
+		// move right by a word.
451
+		t.pos += t.countToRightWord()
452
+		t.moveCursorToPos(t.pos)
453
+	case keyLeft:
454
+		if t.pos == 0 {
455
+			return
456
+		}
457
+		t.pos--
458
+		t.moveCursorToPos(t.pos)
459
+	case keyRight:
460
+		if t.pos == len(t.line) {
461
+			return
462
+		}
463
+		t.pos++
464
+		t.moveCursorToPos(t.pos)
465
+	case keyHome:
466
+		if t.pos == 0 {
467
+			return
468
+		}
469
+		t.pos = 0
470
+		t.moveCursorToPos(t.pos)
471
+	case keyEnd:
472
+		if t.pos == len(t.line) {
473
+			return
474
+		}
475
+		t.pos = len(t.line)
476
+		t.moveCursorToPos(t.pos)
477
+	case keyUp:
478
+		entry, ok := t.history.NthPreviousEntry(t.historyIndex + 1)
479
+		if !ok {
480
+			return "", false
481
+		}
482
+		if t.historyIndex == -1 {
483
+			t.historyPending = string(t.line)
484
+		}
485
+		t.historyIndex++
486
+		runes := []rune(entry)
487
+		t.setLine(runes, len(runes))
488
+	case keyDown:
489
+		switch t.historyIndex {
490
+		case -1:
491
+			return
492
+		case 0:
493
+			runes := []rune(t.historyPending)
494
+			t.setLine(runes, len(runes))
495
+			t.historyIndex--
496
+		default:
497
+			entry, ok := t.history.NthPreviousEntry(t.historyIndex - 1)
498
+			if ok {
499
+				t.historyIndex--
500
+				runes := []rune(entry)
501
+				t.setLine(runes, len(runes))
502
+			}
503
+		}
504
+	case keyEnter:
505
+		t.moveCursorToPos(len(t.line))
506
+		t.queue([]rune("\r\n"))
507
+		line = string(t.line)
508
+		ok = true
509
+		t.line = t.line[:0]
510
+		t.pos = 0
511
+		t.cursorX = 0
512
+		t.cursorY = 0
513
+		t.maxLine = 0
514
+	case keyDeleteWord:
515
+		// Delete zero or more spaces and then one or more characters.
516
+		t.eraseNPreviousChars(t.countToLeftWord())
517
+	case keyDeleteLine:
518
+		// Delete everything from the current cursor position to the
519
+		// end of line.
520
+		for i := t.pos; i < len(t.line); i++ {
521
+			t.queue(space)
522
+			t.advanceCursor(1)
523
+		}
524
+		t.line = t.line[:t.pos]
525
+		t.moveCursorToPos(t.pos)
526
+	case keyCtrlD:
527
+		// Erase the character under the current position.
528
+		// The EOF case when the line is empty is handled in
529
+		// readLine().
530
+		if t.pos < len(t.line) {
531
+			t.pos++
532
+			t.eraseNPreviousChars(1)
533
+		}
534
+	case keyCtrlU:
535
+		t.eraseNPreviousChars(t.pos)
536
+	case keyClearScreen:
537
+		// Erases the screen and moves the cursor to the home position.
538
+		t.queue([]rune("\x1b[2J\x1b[H"))
539
+		t.queue(t.prompt)
540
+		t.cursorX, t.cursorY = 0, 0
541
+		t.advanceCursor(visualLength(t.prompt))
542
+		t.setLine(t.line, t.pos)
543
+	default:
544
+		if t.AutoCompleteCallback != nil {
545
+			prefix := string(t.line[:t.pos])
546
+			suffix := string(t.line[t.pos:])
547
+
548
+			t.lock.Unlock()
549
+			newLine, newPos, completeOk := t.AutoCompleteCallback(prefix+suffix, len(prefix), key)
550
+			t.lock.Lock()
551
+
552
+			if completeOk {
553
+				t.setLine([]rune(newLine), utf8.RuneCount([]byte(newLine)[:newPos]))
554
+				return
555
+			}
556
+		}
557
+		if !isPrintable(key) {
558
+			return
559
+		}
560
+		if len(t.line) == maxLineLength {
561
+			return
562
+		}
563
+		t.addKeyToLine(key)
564
+	}
565
+	return
566
+}
567
+
568
+// addKeyToLine inserts the given key at the current position in the current
569
+// line.
570
+func (t *Terminal) addKeyToLine(key rune) {
571
+	if len(t.line) == cap(t.line) {
572
+		newLine := make([]rune, len(t.line), 2*(1+len(t.line)))
573
+		copy(newLine, t.line)
574
+		t.line = newLine
575
+	}
576
+	t.line = t.line[:len(t.line)+1]
577
+	copy(t.line[t.pos+1:], t.line[t.pos:])
578
+	t.line[t.pos] = key
579
+	if t.echo {
580
+		t.writeLine(t.line[t.pos:])
581
+	}
582
+	t.pos++
583
+	t.moveCursorToPos(t.pos)
584
+}
585
+
586
+func (t *Terminal) writeLine(line []rune) {
587
+	for len(line) != 0 {
588
+		remainingOnLine := t.termWidth - t.cursorX
589
+		todo := len(line)
590
+		if todo > remainingOnLine {
591
+			todo = remainingOnLine
592
+		}
593
+		t.queue(line[:todo])
594
+		t.advanceCursor(visualLength(line[:todo]))
595
+		line = line[todo:]
596
+	}
597
+}
598
+
599
+// writeWithCRLF writes buf to w but replaces all occurrences of \n with \r\n.
600
+func writeWithCRLF(w io.Writer, buf []byte) (n int, err error) {
601
+	for len(buf) > 0 {
602
+		i := bytes.IndexByte(buf, '\n')
603
+		todo := len(buf)
604
+		if i >= 0 {
605
+			todo = i
606
+		}
607
+
608
+		var nn int
609
+		nn, err = w.Write(buf[:todo])
610
+		n += nn
611
+		if err != nil {
612
+			return n, err
613
+		}
614
+		buf = buf[todo:]
615
+
616
+		if i >= 0 {
617
+			if _, err = w.Write(crlf); err != nil {
618
+				return n, err
619
+			}
620
+			n += 1
621
+			buf = buf[1:]
622
+		}
623
+	}
624
+
625
+	return n, nil
626
+}
627
+
628
+func (t *Terminal) Write(buf []byte) (n int, err error) {
629
+	t.lock.Lock()
630
+	defer t.lock.Unlock()
631
+
632
+	if t.cursorX == 0 && t.cursorY == 0 {
633
+		// This is the easy case: there's nothing on the screen that we
634
+		// have to move out of the way.
635
+		return writeWithCRLF(t.c, buf)
636
+	}
637
+
638
+	// We have a prompt and possibly user input on the screen. We
639
+	// have to clear it first.
640
+	t.move(0 /* up */, 0 /* down */, t.cursorX /* left */, 0 /* right */)
641
+	t.cursorX = 0
642
+	t.clearLineToRight()
643
+
644
+	for t.cursorY > 0 {
645
+		t.move(1 /* up */, 0, 0, 0)
646
+		t.cursorY--
647
+		t.clearLineToRight()
648
+	}
649
+
650
+	if _, err = t.c.Write(t.outBuf); err != nil {
651
+		return
652
+	}
653
+	t.outBuf = t.outBuf[:0]
654
+
655
+	if n, err = writeWithCRLF(t.c, buf); err != nil {
656
+		return
657
+	}
658
+
659
+	t.writeLine(t.prompt)
660
+	if t.echo {
661
+		t.writeLine(t.line)
662
+	}
663
+
664
+	t.moveCursorToPos(t.pos)
665
+
666
+	if _, err = t.c.Write(t.outBuf); err != nil {
667
+		return
668
+	}
669
+	t.outBuf = t.outBuf[:0]
670
+	return
671
+}
672
+
673
+// ReadPassword temporarily changes the prompt and reads a password, without
674
+// echo, from the terminal.
675
+func (t *Terminal) ReadPassword(prompt string) (line string, err error) {
676
+	t.lock.Lock()
677
+	defer t.lock.Unlock()
678
+
679
+	oldPrompt := t.prompt
680
+	t.prompt = []rune(prompt)
681
+	t.echo = false
682
+
683
+	line, err = t.readLine()
684
+
685
+	t.prompt = oldPrompt
686
+	t.echo = true
687
+
688
+	return
689
+}
690
+
691
+// ReadLine returns a line of input from the terminal.
692
+func (t *Terminal) ReadLine() (line string, err error) {
693
+	t.lock.Lock()
694
+	defer t.lock.Unlock()
695
+
696
+	return t.readLine()
697
+}
698
+
699
+func (t *Terminal) readLine() (line string, err error) {
700
+	// t.lock must be held at this point
701
+
702
+	if t.cursorX == 0 && t.cursorY == 0 {
703
+		t.writeLine(t.prompt)
704
+		t.c.Write(t.outBuf)
705
+		t.outBuf = t.outBuf[:0]
706
+	}
707
+
708
+	lineIsPasted := t.pasteActive
709
+
710
+	for {
711
+		rest := t.remainder
712
+		lineOk := false
713
+		for !lineOk {
714
+			var key rune
715
+			key, rest = bytesToKey(rest, t.pasteActive)
716
+			if key == utf8.RuneError {
717
+				break
718
+			}
719
+			if !t.pasteActive {
720
+				if key == keyCtrlD {
721
+					if len(t.line) == 0 {
722
+						return "", io.EOF
723
+					}
724
+				}
725
+				if key == keyPasteStart {
726
+					t.pasteActive = true
727
+					if len(t.line) == 0 {
728
+						lineIsPasted = true
729
+					}
730
+					continue
731
+				}
732
+			} else if key == keyPasteEnd {
733
+				t.pasteActive = false
734
+				continue
735
+			}
736
+			if !t.pasteActive {
737
+				lineIsPasted = false
738
+			}
739
+			line, lineOk = t.handleKey(key)
740
+		}
741
+		if len(rest) > 0 {
742
+			n := copy(t.inBuf[:], rest)
743
+			t.remainder = t.inBuf[:n]
744
+		} else {
745
+			t.remainder = nil
746
+		}
747
+		t.c.Write(t.outBuf)
748
+		t.outBuf = t.outBuf[:0]
749
+		if lineOk {
750
+			if t.echo {
751
+				t.historyIndex = -1
752
+				t.history.Add(line)
753
+			}
754
+			if lineIsPasted {
755
+				err = ErrPasteIndicator
756
+			}
757
+			return
758
+		}
759
+
760
+		// t.remainder is a slice at the beginning of t.inBuf
761
+		// containing a partial key sequence
762
+		readBuf := t.inBuf[len(t.remainder):]
763
+		var n int
764
+
765
+		t.lock.Unlock()
766
+		n, err = t.c.Read(readBuf)
767
+		t.lock.Lock()
768
+
769
+		if err != nil {
770
+			return
771
+		}
772
+
773
+		t.remainder = t.inBuf[:n+len(t.remainder)]
774
+	}
775
+}
776
+
777
+// SetPrompt sets the prompt to be used when reading subsequent lines.
778
+func (t *Terminal) SetPrompt(prompt string) {
779
+	t.lock.Lock()
780
+	defer t.lock.Unlock()
781
+
782
+	t.prompt = []rune(prompt)
783
+}
784
+
785
+func (t *Terminal) clearAndRepaintLinePlusNPrevious(numPrevLines int) {
786
+	// Move cursor to column zero at the start of the line.
787
+	t.move(t.cursorY, 0, t.cursorX, 0)
788
+	t.cursorX, t.cursorY = 0, 0
789
+	t.clearLineToRight()
790
+	for t.cursorY < numPrevLines {
791
+		// Move down a line
792
+		t.move(0, 1, 0, 0)
793
+		t.cursorY++
794
+		t.clearLineToRight()
795
+	}
796
+	// Move back to beginning.
797
+	t.move(t.cursorY, 0, 0, 0)
798
+	t.cursorX, t.cursorY = 0, 0
799
+
800
+	t.queue(t.prompt)
801
+	t.advanceCursor(visualLength(t.prompt))
802
+	t.writeLine(t.line)
803
+	t.moveCursorToPos(t.pos)
804
+}
805
+
806
+func (t *Terminal) SetSize(width, height int) error {
807
+	t.lock.Lock()
808
+	defer t.lock.Unlock()
809
+
810
+	if width == 0 {
811
+		width = 1
812
+	}
813
+
814
+	oldWidth := t.termWidth
815
+	t.termWidth, t.termHeight = width, height
816
+
817
+	switch {
818
+	case width == oldWidth:
819
+		// If the width didn't change then nothing else needs to be
820
+		// done.
821
+		return nil
822
+	case len(t.line) == 0 && t.cursorX == 0 && t.cursorY == 0:
823
+		// If there is nothing on current line and no prompt printed,
824
+		// just do nothing
825
+		return nil
826
+	case width < oldWidth:
827
+		// Some terminals (e.g. xterm) will truncate lines that were
828
+		// too long when shinking. Others, (e.g. gnome-terminal) will
829
+		// attempt to wrap them. For the former, repainting t.maxLine
830
+		// works great, but that behaviour goes badly wrong in the case
831
+		// of the latter because they have doubled every full line.
832
+
833
+		// We assume that we are working on a terminal that wraps lines
834
+		// and adjust the cursor position based on every previous line
835
+		// wrapping and turning into two. This causes the prompt on
836
+		// xterms to move upwards, which isn't great, but it avoids a
837
+		// huge mess with gnome-terminal.
838
+		if t.cursorX >= t.termWidth {
839
+			t.cursorX = t.termWidth - 1
840
+		}
841
+		t.cursorY *= 2
842
+		t.clearAndRepaintLinePlusNPrevious(t.maxLine * 2)
843
+	case width > oldWidth:
844
+		// If the terminal expands then our position calculations will
845
+		// be wrong in the future because we think the cursor is
846
+		// |t.pos| chars into the string, but there will be a gap at
847
+		// the end of any wrapped line.
848
+		//
849
+		// But the position will actually be correct until we move, so
850
+		// we can move back to the beginning and repaint everything.
851
+		t.clearAndRepaintLinePlusNPrevious(t.maxLine)
852
+	}
853
+
854
+	_, err := t.c.Write(t.outBuf)
855
+	t.outBuf = t.outBuf[:0]
856
+	return err
857
+}
858
+
859
+type pasteIndicatorError struct{}
860
+
861
+func (pasteIndicatorError) Error() string {
862
+	return "terminal: ErrPasteIndicator not correctly handled"
863
+}
864
+
865
+// ErrPasteIndicator may be returned from ReadLine as the error, in addition
866
+// to valid line data. It indicates that bracketed paste mode is enabled and
867
+// that the returned line consists only of pasted data. Programs may wish to
868
+// interpret pasted data more literally than typed data.
869
+var ErrPasteIndicator = pasteIndicatorError{}
870
+
871
+// SetBracketedPasteMode requests that the terminal bracket paste operations
872
+// with markers. Not all terminals support this but, if it is supported, then
873
+// enabling this mode will stop any autocomplete callback from running due to
874
+// pastes. Additionally, any lines that are completely pasted will be returned
875
+// from ReadLine with the error set to ErrPasteIndicator.
876
+func (t *Terminal) SetBracketedPasteMode(on bool) {
877
+	if on {
878
+		io.WriteString(t.c, "\x1b[?2004h")
879
+	} else {
880
+		io.WriteString(t.c, "\x1b[?2004l")
881
+	}
882
+}
883
+
884
+// stRingBuffer is a ring buffer of strings.
885
+type stRingBuffer struct {
886
+	// entries contains max elements.
887
+	entries []string
888
+	max     int
889
+	// head contains the index of the element most recently added to the ring.
890
+	head int
891
+	// size contains the number of elements in the ring.
892
+	size int
893
+}
894
+
895
+func (s *stRingBuffer) Add(a string) {
896
+	if s.entries == nil {
897
+		const defaultNumEntries = 100
898
+		s.entries = make([]string, defaultNumEntries)
899
+		s.max = defaultNumEntries
900
+	}
901
+
902
+	s.head = (s.head + 1) % s.max
903
+	s.entries[s.head] = a
904
+	if s.size < s.max {
905
+		s.size++
906
+	}
907
+}
908
+
909
+// NthPreviousEntry returns the value passed to the nth previous call to Add.
910
+// If n is zero then the immediately prior value is returned, if one, then the
911
+// next most recent, and so on. If such an element doesn't exist then ok is
912
+// false.
913
+func (s *stRingBuffer) NthPreviousEntry(n int) (value string, ok bool) {
914
+	if n >= s.size {
915
+		return "", false
916
+	}
917
+	index := s.head - n
918
+	if index < 0 {
919
+		index += s.max
920
+	}
921
+	return s.entries[index], true
922
+}
923
+
924
+// readPasswordLine reads from reader until it finds \n or io.EOF.
925
+// The slice returned does not include the \n.
926
+// readPasswordLine also ignores any \r it finds.
927
+func readPasswordLine(reader io.Reader) ([]byte, error) {
928
+	var buf [1]byte
929
+	var ret []byte
930
+
931
+	for {
932
+		n, err := reader.Read(buf[:])
933
+		if n > 0 {
934
+			switch buf[0] {
935
+			case '\n':
936
+				return ret, nil
937
+			case '\r':
938
+				// remove \r from passwords on Windows
939
+			default:
940
+				ret = append(ret, buf[0])
941
+			}
942
+			continue
943
+		}
944
+		if err != nil {
945
+			if err == io.EOF && len(ret) > 0 {
946
+				return ret, nil
947
+			}
948
+			return ret, err
949
+		}
950
+	}
951
+}

+ 350
- 0
vendor/src/golang.org/x/crypto/ssh/terminal/terminal_test.go Ver fichero

@@ -0,0 +1,350 @@
1
+// Copyright 2011 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
+package terminal
6
+
7
+import (
8
+	"bytes"
9
+	"io"
10
+	"os"
11
+	"testing"
12
+)
13
+
14
+type MockTerminal struct {
15
+	toSend       []byte
16
+	bytesPerRead int
17
+	received     []byte
18
+}
19
+
20
+func (c *MockTerminal) Read(data []byte) (n int, err error) {
21
+	n = len(data)
22
+	if n == 0 {
23
+		return
24
+	}
25
+	if n > len(c.toSend) {
26
+		n = len(c.toSend)
27
+	}
28
+	if n == 0 {
29
+		return 0, io.EOF
30
+	}
31
+	if c.bytesPerRead > 0 && n > c.bytesPerRead {
32
+		n = c.bytesPerRead
33
+	}
34
+	copy(data, c.toSend[:n])
35
+	c.toSend = c.toSend[n:]
36
+	return
37
+}
38
+
39
+func (c *MockTerminal) Write(data []byte) (n int, err error) {
40
+	c.received = append(c.received, data...)
41
+	return len(data), nil
42
+}
43
+
44
+func TestClose(t *testing.T) {
45
+	c := &MockTerminal{}
46
+	ss := NewTerminal(c, "> ")
47
+	line, err := ss.ReadLine()
48
+	if line != "" {
49
+		t.Errorf("Expected empty line but got: %s", line)
50
+	}
51
+	if err != io.EOF {
52
+		t.Errorf("Error should have been EOF but got: %s", err)
53
+	}
54
+}
55
+
56
+var keyPressTests = []struct {
57
+	in             string
58
+	line           string
59
+	err            error
60
+	throwAwayLines int
61
+}{
62
+	{
63
+		err: io.EOF,
64
+	},
65
+	{
66
+		in:   "\r",
67
+		line: "",
68
+	},
69
+	{
70
+		in:   "foo\r",
71
+		line: "foo",
72
+	},
73
+	{
74
+		in:   "a\x1b[Cb\r", // right
75
+		line: "ab",
76
+	},
77
+	{
78
+		in:   "a\x1b[Db\r", // left
79
+		line: "ba",
80
+	},
81
+	{
82
+		in:   "a\177b\r", // backspace
83
+		line: "b",
84
+	},
85
+	{
86
+		in: "\x1b[A\r", // up
87
+	},
88
+	{
89
+		in: "\x1b[B\r", // down
90
+	},
91
+	{
92
+		in:   "line\x1b[A\x1b[B\r", // up then down
93
+		line: "line",
94
+	},
95
+	{
96
+		in:             "line1\rline2\x1b[A\r", // recall previous line.
97
+		line:           "line1",
98
+		throwAwayLines: 1,
99
+	},
100
+	{
101
+		// recall two previous lines and append.
102
+		in:             "line1\rline2\rline3\x1b[A\x1b[Axxx\r",
103
+		line:           "line1xxx",
104
+		throwAwayLines: 2,
105
+	},
106
+	{
107
+		// Ctrl-A to move to beginning of line followed by ^K to kill
108
+		// line.
109
+		in:   "a b \001\013\r",
110
+		line: "",
111
+	},
112
+	{
113
+		// Ctrl-A to move to beginning of line, Ctrl-E to move to end,
114
+		// finally ^K to kill nothing.
115
+		in:   "a b \001\005\013\r",
116
+		line: "a b ",
117
+	},
118
+	{
119
+		in:   "\027\r",
120
+		line: "",
121
+	},
122
+	{
123
+		in:   "a\027\r",
124
+		line: "",
125
+	},
126
+	{
127
+		in:   "a \027\r",
128
+		line: "",
129
+	},
130
+	{
131
+		in:   "a b\027\r",
132
+		line: "a ",
133
+	},
134
+	{
135
+		in:   "a b \027\r",
136
+		line: "a ",
137
+	},
138
+	{
139
+		in:   "one two thr\x1b[D\027\r",
140
+		line: "one two r",
141
+	},
142
+	{
143
+		in:   "\013\r",
144
+		line: "",
145
+	},
146
+	{
147
+		in:   "a\013\r",
148
+		line: "a",
149
+	},
150
+	{
151
+		in:   "ab\x1b[D\013\r",
152
+		line: "a",
153
+	},
154
+	{
155
+		in:   "Ξεσκεπάζω\r",
156
+		line: "Ξεσκεπάζω",
157
+	},
158
+	{
159
+		in:             "£\r\x1b[A\177\r", // non-ASCII char, enter, up, backspace.
160
+		line:           "",
161
+		throwAwayLines: 1,
162
+	},
163
+	{
164
+		in:             "£\r££\x1b[A\x1b[B\177\r", // non-ASCII char, enter, 2x non-ASCII, up, down, backspace, enter.
165
+		line:           "£",
166
+		throwAwayLines: 1,
167
+	},
168
+	{
169
+		// Ctrl-D at the end of the line should be ignored.
170
+		in:   "a\004\r",
171
+		line: "a",
172
+	},
173
+	{
174
+		// a, b, left, Ctrl-D should erase the b.
175
+		in:   "ab\x1b[D\004\r",
176
+		line: "a",
177
+	},
178
+	{
179
+		// a, b, c, d, left, left, ^U should erase to the beginning of
180
+		// the line.
181
+		in:   "abcd\x1b[D\x1b[D\025\r",
182
+		line: "cd",
183
+	},
184
+	{
185
+		// Bracketed paste mode: control sequences should be returned
186
+		// verbatim in paste mode.
187
+		in:   "abc\x1b[200~de\177f\x1b[201~\177\r",
188
+		line: "abcde\177",
189
+	},
190
+	{
191
+		// Enter in bracketed paste mode should still work.
192
+		in:             "abc\x1b[200~d\refg\x1b[201~h\r",
193
+		line:           "efgh",
194
+		throwAwayLines: 1,
195
+	},
196
+	{
197
+		// Lines consisting entirely of pasted data should be indicated as such.
198
+		in:   "\x1b[200~a\r",
199
+		line: "a",
200
+		err:  ErrPasteIndicator,
201
+	},
202
+}
203
+
204
+func TestKeyPresses(t *testing.T) {
205
+	for i, test := range keyPressTests {
206
+		for j := 1; j < len(test.in); j++ {
207
+			c := &MockTerminal{
208
+				toSend:       []byte(test.in),
209
+				bytesPerRead: j,
210
+			}
211
+			ss := NewTerminal(c, "> ")
212
+			for k := 0; k < test.throwAwayLines; k++ {
213
+				_, err := ss.ReadLine()
214
+				if err != nil {
215
+					t.Errorf("Throwaway line %d from test %d resulted in error: %s", k, i, err)
216
+				}
217
+			}
218
+			line, err := ss.ReadLine()
219
+			if line != test.line {
220
+				t.Errorf("Line resulting from test %d (%d bytes per read) was '%s', expected '%s'", i, j, line, test.line)
221
+				break
222
+			}
223
+			if err != test.err {
224
+				t.Errorf("Error resulting from test %d (%d bytes per read) was '%v', expected '%v'", i, j, err, test.err)
225
+				break
226
+			}
227
+		}
228
+	}
229
+}
230
+
231
+func TestPasswordNotSaved(t *testing.T) {
232
+	c := &MockTerminal{
233
+		toSend:       []byte("password\r\x1b[A\r"),
234
+		bytesPerRead: 1,
235
+	}
236
+	ss := NewTerminal(c, "> ")
237
+	pw, _ := ss.ReadPassword("> ")
238
+	if pw != "password" {
239
+		t.Fatalf("failed to read password, got %s", pw)
240
+	}
241
+	line, _ := ss.ReadLine()
242
+	if len(line) > 0 {
243
+		t.Fatalf("password was saved in history")
244
+	}
245
+}
246
+
247
+var setSizeTests = []struct {
248
+	width, height int
249
+}{
250
+	{40, 13},
251
+	{80, 24},
252
+	{132, 43},
253
+}
254
+
255
+func TestTerminalSetSize(t *testing.T) {
256
+	for _, setSize := range setSizeTests {
257
+		c := &MockTerminal{
258
+			toSend:       []byte("password\r\x1b[A\r"),
259
+			bytesPerRead: 1,
260
+		}
261
+		ss := NewTerminal(c, "> ")
262
+		ss.SetSize(setSize.width, setSize.height)
263
+		pw, _ := ss.ReadPassword("Password: ")
264
+		if pw != "password" {
265
+			t.Fatalf("failed to read password, got %s", pw)
266
+		}
267
+		if string(c.received) != "Password: \r\n" {
268
+			t.Errorf("failed to set the temporary prompt expected %q, got %q", "Password: ", c.received)
269
+		}
270
+	}
271
+}
272
+
273
+func TestReadPasswordLineEnd(t *testing.T) {
274
+	var tests = []struct {
275
+		input string
276
+		want  string
277
+	}{
278
+		{"\n", ""},
279
+		{"\r\n", ""},
280
+		{"test\r\n", "test"},
281
+		{"testtesttesttes\n", "testtesttesttes"},
282
+		{"testtesttesttes\r\n", "testtesttesttes"},
283
+		{"testtesttesttesttest\n", "testtesttesttesttest"},
284
+		{"testtesttesttesttest\r\n", "testtesttesttesttest"},
285
+	}
286
+	for _, test := range tests {
287
+		buf := new(bytes.Buffer)
288
+		if _, err := buf.WriteString(test.input); err != nil {
289
+			t.Fatal(err)
290
+		}
291
+
292
+		have, err := readPasswordLine(buf)
293
+		if err != nil {
294
+			t.Errorf("readPasswordLine(%q) failed: %v", test.input, err)
295
+			continue
296
+		}
297
+		if string(have) != test.want {
298
+			t.Errorf("readPasswordLine(%q) returns %q, but %q is expected", test.input, string(have), test.want)
299
+			continue
300
+		}
301
+
302
+		if _, err = buf.WriteString(test.input); err != nil {
303
+			t.Fatal(err)
304
+		}
305
+		have, err = readPasswordLine(buf)
306
+		if err != nil {
307
+			t.Errorf("readPasswordLine(%q) failed: %v", test.input, err)
308
+			continue
309
+		}
310
+		if string(have) != test.want {
311
+			t.Errorf("readPasswordLine(%q) returns %q, but %q is expected", test.input, string(have), test.want)
312
+			continue
313
+		}
314
+	}
315
+}
316
+
317
+func TestMakeRawState(t *testing.T) {
318
+	fd := int(os.Stdout.Fd())
319
+	if !IsTerminal(fd) {
320
+		t.Skip("stdout is not a terminal; skipping test")
321
+	}
322
+
323
+	st, err := GetState(fd)
324
+	if err != nil {
325
+		t.Fatalf("failed to get terminal state from GetState: %s", err)
326
+	}
327
+	defer Restore(fd, st)
328
+	raw, err := MakeRaw(fd)
329
+	if err != nil {
330
+		t.Fatalf("failed to get terminal state from MakeRaw: %s", err)
331
+	}
332
+
333
+	if *st != *raw {
334
+		t.Errorf("states do not match; was %v, expected %v", raw, st)
335
+	}
336
+}
337
+
338
+func TestOutputNewlines(t *testing.T) {
339
+	// \n should be changed to \r\n in terminal output.
340
+	buf := new(bytes.Buffer)
341
+	term := NewTerminal(buf, ">")
342
+
343
+	term.Write([]byte("1\n2\n"))
344
+	output := string(buf.Bytes())
345
+	const expected = "1\r\n2\r\n"
346
+
347
+	if output != expected {
348
+		t.Errorf("incorrect output: was %q, expected %q", output, expected)
349
+	}
350
+}

+ 116
- 0
vendor/src/golang.org/x/crypto/ssh/terminal/util.go Ver fichero

@@ -0,0 +1,116 @@
1
+// Copyright 2011 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
+// +build darwin dragonfly freebsd linux,!appengine netbsd openbsd
6
+
7
+// Package terminal provides support functions for dealing with terminals, as
8
+// commonly found on UNIX systems.
9
+//
10
+// Putting a terminal into raw mode is the most common requirement:
11
+//
12
+// 	oldState, err := terminal.MakeRaw(0)
13
+// 	if err != nil {
14
+// 	        panic(err)
15
+// 	}
16
+// 	defer terminal.Restore(0, oldState)
17
+package terminal // import "golang.org/x/crypto/ssh/terminal"
18
+
19
+import (
20
+	"golang.org/x/sys/unix"
21
+)
22
+
23
+// State contains the state of a terminal.
24
+type State struct {
25
+	termios unix.Termios
26
+}
27
+
28
+// IsTerminal returns true if the given file descriptor is a terminal.
29
+func IsTerminal(fd int) bool {
30
+	_, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
31
+	return err == nil
32
+}
33
+
34
+// MakeRaw put the terminal connected to the given file descriptor into raw
35
+// mode and returns the previous state of the terminal so that it can be
36
+// restored.
37
+func MakeRaw(fd int) (*State, error) {
38
+	termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
39
+	if err != nil {
40
+		return nil, err
41
+	}
42
+
43
+	oldState := State{termios: *termios}
44
+
45
+	// This attempts to replicate the behaviour documented for cfmakeraw in
46
+	// the termios(3) manpage.
47
+	termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
48
+	termios.Oflag &^= unix.OPOST
49
+	termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN
50
+	termios.Cflag &^= unix.CSIZE | unix.PARENB
51
+	termios.Cflag |= unix.CS8
52
+	termios.Cc[unix.VMIN] = 1
53
+	termios.Cc[unix.VTIME] = 0
54
+	if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, termios); err != nil {
55
+		return nil, err
56
+	}
57
+
58
+	return &oldState, nil
59
+}
60
+
61
+// GetState returns the current state of a terminal which may be useful to
62
+// restore the terminal after a signal.
63
+func GetState(fd int) (*State, error) {
64
+	termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
65
+	if err != nil {
66
+		return nil, err
67
+	}
68
+
69
+	return &State{termios: *termios}, nil
70
+}
71
+
72
+// Restore restores the terminal connected to the given file descriptor to a
73
+// previous state.
74
+func Restore(fd int, state *State) error {
75
+	return unix.IoctlSetTermios(fd, ioctlWriteTermios, &state.termios)
76
+}
77
+
78
+// GetSize returns the dimensions of the given terminal.
79
+func GetSize(fd int) (width, height int, err error) {
80
+	ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)
81
+	if err != nil {
82
+		return -1, -1, err
83
+	}
84
+	return int(ws.Col), int(ws.Row), nil
85
+}
86
+
87
+// passwordReader is an io.Reader that reads from a specific file descriptor.
88
+type passwordReader int
89
+
90
+func (r passwordReader) Read(buf []byte) (int, error) {
91
+	return unix.Read(int(r), buf)
92
+}
93
+
94
+// ReadPassword reads a line of input from a terminal without local echo.  This
95
+// is commonly used for inputting passwords and other sensitive data. The slice
96
+// returned does not include the \n.
97
+func ReadPassword(fd int) ([]byte, error) {
98
+	termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
99
+	if err != nil {
100
+		return nil, err
101
+	}
102
+
103
+	newState := *termios
104
+	newState.Lflag &^= unix.ECHO
105
+	newState.Lflag |= unix.ICANON | unix.ISIG
106
+	newState.Iflag |= unix.ICRNL
107
+	if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, &newState); err != nil {
108
+		return nil, err
109
+	}
110
+
111
+	defer func() {
112
+		unix.IoctlSetTermios(fd, ioctlWriteTermios, termios)
113
+	}()
114
+
115
+	return readPasswordLine(passwordReader(fd))
116
+}

+ 12
- 0
vendor/src/golang.org/x/crypto/ssh/terminal/util_bsd.go Ver fichero

@@ -0,0 +1,12 @@
1
+// Copyright 2013 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
+// +build darwin dragonfly freebsd netbsd openbsd
6
+
7
+package terminal
8
+
9
+import "golang.org/x/sys/unix"
10
+
11
+const ioctlReadTermios = unix.TIOCGETA
12
+const ioctlWriteTermios = unix.TIOCSETA

+ 10
- 0
vendor/src/golang.org/x/crypto/ssh/terminal/util_linux.go Ver fichero

@@ -0,0 +1,10 @@
1
+// Copyright 2013 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
+package terminal
6
+
7
+import "golang.org/x/sys/unix"
8
+
9
+const ioctlReadTermios = unix.TCGETS
10
+const ioctlWriteTermios = unix.TCSETS

+ 58
- 0
vendor/src/golang.org/x/crypto/ssh/terminal/util_plan9.go Ver fichero

@@ -0,0 +1,58 @@
1
+// Copyright 2016 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
+// Package terminal provides support functions for dealing with terminals, as
6
+// commonly found on UNIX systems.
7
+//
8
+// Putting a terminal into raw mode is the most common requirement:
9
+//
10
+// 	oldState, err := terminal.MakeRaw(0)
11
+// 	if err != nil {
12
+// 	        panic(err)
13
+// 	}
14
+// 	defer terminal.Restore(0, oldState)
15
+package terminal
16
+
17
+import (
18
+	"fmt"
19
+	"runtime"
20
+)
21
+
22
+type State struct{}
23
+
24
+// IsTerminal returns true if the given file descriptor is a terminal.
25
+func IsTerminal(fd int) bool {
26
+	return false
27
+}
28
+
29
+// MakeRaw put the terminal connected to the given file descriptor into raw
30
+// mode and returns the previous state of the terminal so that it can be
31
+// restored.
32
+func MakeRaw(fd int) (*State, error) {
33
+	return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
34
+}
35
+
36
+// GetState returns the current state of a terminal which may be useful to
37
+// restore the terminal after a signal.
38
+func GetState(fd int) (*State, error) {
39
+	return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
40
+}
41
+
42
+// Restore restores the terminal connected to the given file descriptor to a
43
+// previous state.
44
+func Restore(fd int, state *State) error {
45
+	return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
46
+}
47
+
48
+// GetSize returns the dimensions of the given terminal.
49
+func GetSize(fd int) (width, height int, err error) {
50
+	return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
51
+}
52
+
53
+// ReadPassword reads a line of input from a terminal without local echo.  This
54
+// is commonly used for inputting passwords and other sensitive data. The slice
55
+// returned does not include the \n.
56
+func ReadPassword(fd int) ([]byte, error) {
57
+	return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
58
+}

+ 128
- 0
vendor/src/golang.org/x/crypto/ssh/terminal/util_solaris.go Ver fichero

@@ -0,0 +1,128 @@
1
+// Copyright 2015 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
+// +build solaris
6
+
7
+package terminal // import "golang.org/x/crypto/ssh/terminal"
8
+
9
+import (
10
+	"golang.org/x/sys/unix"
11
+	"io"
12
+	"syscall"
13
+)
14
+
15
+// State contains the state of a terminal.
16
+type State struct {
17
+	state *unix.Termios
18
+}
19
+
20
+// IsTerminal returns true if the given file descriptor is a terminal.
21
+func IsTerminal(fd int) bool {
22
+	_, err := unix.IoctlGetTermio(fd, unix.TCGETA)
23
+	return err == nil
24
+}
25
+
26
+// ReadPassword reads a line of input from a terminal without local echo.  This
27
+// is commonly used for inputting passwords and other sensitive data. The slice
28
+// returned does not include the \n.
29
+func ReadPassword(fd int) ([]byte, error) {
30
+	// see also: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libast/common/uwin/getpass.c
31
+	val, err := unix.IoctlGetTermios(fd, unix.TCGETS)
32
+	if err != nil {
33
+		return nil, err
34
+	}
35
+	oldState := *val
36
+
37
+	newState := oldState
38
+	newState.Lflag &^= syscall.ECHO
39
+	newState.Lflag |= syscall.ICANON | syscall.ISIG
40
+	newState.Iflag |= syscall.ICRNL
41
+	err = unix.IoctlSetTermios(fd, unix.TCSETS, &newState)
42
+	if err != nil {
43
+		return nil, err
44
+	}
45
+
46
+	defer unix.IoctlSetTermios(fd, unix.TCSETS, &oldState)
47
+
48
+	var buf [16]byte
49
+	var ret []byte
50
+	for {
51
+		n, err := syscall.Read(fd, buf[:])
52
+		if err != nil {
53
+			return nil, err
54
+		}
55
+		if n == 0 {
56
+			if len(ret) == 0 {
57
+				return nil, io.EOF
58
+			}
59
+			break
60
+		}
61
+		if buf[n-1] == '\n' {
62
+			n--
63
+		}
64
+		ret = append(ret, buf[:n]...)
65
+		if n < len(buf) {
66
+			break
67
+		}
68
+	}
69
+
70
+	return ret, nil
71
+}
72
+
73
+// MakeRaw puts the terminal connected to the given file descriptor into raw
74
+// mode and returns the previous state of the terminal so that it can be
75
+// restored.
76
+// see http://cr.illumos.org/~webrev/andy_js/1060/
77
+func MakeRaw(fd int) (*State, error) {
78
+	oldTermiosPtr, err := unix.IoctlGetTermios(fd, unix.TCGETS)
79
+	if err != nil {
80
+		return nil, err
81
+	}
82
+	oldTermios := *oldTermiosPtr
83
+
84
+	newTermios := oldTermios
85
+	newTermios.Iflag &^= syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON
86
+	newTermios.Oflag &^= syscall.OPOST
87
+	newTermios.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN
88
+	newTermios.Cflag &^= syscall.CSIZE | syscall.PARENB
89
+	newTermios.Cflag |= syscall.CS8
90
+	newTermios.Cc[unix.VMIN] = 1
91
+	newTermios.Cc[unix.VTIME] = 0
92
+
93
+	if err := unix.IoctlSetTermios(fd, unix.TCSETS, &newTermios); err != nil {
94
+		return nil, err
95
+	}
96
+
97
+	return &State{
98
+		state: oldTermiosPtr,
99
+	}, nil
100
+}
101
+
102
+// Restore restores the terminal connected to the given file descriptor to a
103
+// previous state.
104
+func Restore(fd int, oldState *State) error {
105
+	return unix.IoctlSetTermios(fd, unix.TCSETS, oldState.state)
106
+}
107
+
108
+// GetState returns the current state of a terminal which may be useful to
109
+// restore the terminal after a signal.
110
+func GetState(fd int) (*State, error) {
111
+	oldTermiosPtr, err := unix.IoctlGetTermios(fd, unix.TCGETS)
112
+	if err != nil {
113
+		return nil, err
114
+	}
115
+
116
+	return &State{
117
+		state: oldTermiosPtr,
118
+	}, nil
119
+}
120
+
121
+// GetSize returns the dimensions of the given terminal.
122
+func GetSize(fd int) (width, height int, err error) {
123
+	ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)
124
+	if err != nil {
125
+		return 0, 0, err
126
+	}
127
+	return int(ws.Col), int(ws.Row), nil
128
+}

+ 102
- 0
vendor/src/golang.org/x/crypto/ssh/terminal/util_windows.go Ver fichero

@@ -0,0 +1,102 @@
1
+// Copyright 2011 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
+// +build windows
6
+
7
+// Package terminal provides support functions for dealing with terminals, as
8
+// commonly found on UNIX systems.
9
+//
10
+// Putting a terminal into raw mode is the most common requirement:
11
+//
12
+// 	oldState, err := terminal.MakeRaw(0)
13
+// 	if err != nil {
14
+// 	        panic(err)
15
+// 	}
16
+// 	defer terminal.Restore(0, oldState)
17
+package terminal
18
+
19
+import (
20
+	"golang.org/x/sys/windows"
21
+)
22
+
23
+type State struct {
24
+	mode uint32
25
+}
26
+
27
+// IsTerminal returns true if the given file descriptor is a terminal.
28
+func IsTerminal(fd int) bool {
29
+	var st uint32
30
+	err := windows.GetConsoleMode(windows.Handle(fd), &st)
31
+	return err == nil
32
+}
33
+
34
+// MakeRaw put the terminal connected to the given file descriptor into raw
35
+// mode and returns the previous state of the terminal so that it can be
36
+// restored.
37
+func MakeRaw(fd int) (*State, error) {
38
+	var st uint32
39
+	if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
40
+		return nil, err
41
+	}
42
+	raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT)
43
+	if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil {
44
+		return nil, err
45
+	}
46
+	return &State{st}, nil
47
+}
48
+
49
+// GetState returns the current state of a terminal which may be useful to
50
+// restore the terminal after a signal.
51
+func GetState(fd int) (*State, error) {
52
+	var st uint32
53
+	if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
54
+		return nil, err
55
+	}
56
+	return &State{st}, nil
57
+}
58
+
59
+// Restore restores the terminal connected to the given file descriptor to a
60
+// previous state.
61
+func Restore(fd int, state *State) error {
62
+	return windows.SetConsoleMode(windows.Handle(fd), state.mode)
63
+}
64
+
65
+// GetSize returns the dimensions of the given terminal.
66
+func GetSize(fd int) (width, height int, err error) {
67
+	var info windows.ConsoleScreenBufferInfo
68
+	if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
69
+		return 0, 0, err
70
+	}
71
+	return int(info.Size.X), int(info.Size.Y), nil
72
+}
73
+
74
+// passwordReader is an io.Reader that reads from a specific Windows HANDLE.
75
+type passwordReader int
76
+
77
+func (r passwordReader) Read(buf []byte) (int, error) {
78
+	return windows.Read(windows.Handle(r), buf)
79
+}
80
+
81
+// ReadPassword reads a line of input from a terminal without local echo.  This
82
+// is commonly used for inputting passwords and other sensitive data. The slice
83
+// returned does not include the \n.
84
+func ReadPassword(fd int) ([]byte, error) {
85
+	var st uint32
86
+	if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
87
+		return nil, err
88
+	}
89
+	old := st
90
+
91
+	st &^= (windows.ENABLE_ECHO_INPUT)
92
+	st |= (windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT)
93
+	if err := windows.SetConsoleMode(windows.Handle(fd), st); err != nil {
94
+		return nil, err
95
+	}
96
+
97
+	defer func() {
98
+		windows.SetConsoleMode(windows.Handle(fd), old)
99
+	}()
100
+
101
+	return readPasswordLine(passwordReader(fd))
102
+}

+ 173
- 0
vendor/src/golang.org/x/sys/unix/README.md Ver fichero

@@ -0,0 +1,173 @@
1
+# Building `sys/unix`
2
+
3
+The sys/unix package provides access to the raw system call interface of the
4
+underlying operating system. See: https://godoc.org/golang.org/x/sys/unix
5
+
6
+Porting Go to a new architecture/OS combination or adding syscalls, types, or
7
+constants to an existing architecture/OS pair requires some manual effort;
8
+however, there are tools that automate much of the process.
9
+
10
+## Build Systems
11
+
12
+There are currently two ways we generate the necessary files. We are currently
13
+migrating the build system to use containers so the builds are reproducible.
14
+This is being done on an OS-by-OS basis. Please update this documentation as
15
+components of the build system change.
16
+
17
+### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`)
18
+
19
+The old build system generates the Go files based on the C header files
20
+present on your system. This means that files
21
+for a given GOOS/GOARCH pair must be generated on a system with that OS and
22
+architecture. This also means that the generated code can differ from system
23
+to system, based on differences in the header files.
24
+
25
+To avoid this, if you are using the old build system, only generate the Go
26
+files on an installation with unmodified header files. It is also important to
27
+keep track of which version of the OS the files were generated from (ex.
28
+Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes
29
+and have each OS upgrade correspond to a single change.
30
+
31
+To build the files for your current OS and architecture, make sure GOOS and
32
+GOARCH are set correctly and run `mkall.sh`. This will generate the files for
33
+your specific system. Running `mkall.sh -n` shows the commands that will be run.
34
+
35
+Requirements: bash, perl, go
36
+
37
+### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`)
38
+
39
+The new build system uses a Docker container to generate the go files directly
40
+from source checkouts of the kernel and various system libraries. This means
41
+that on any platform that supports Docker, all the files using the new build
42
+system can be generated at once, and generated files will not change based on
43
+what the person running the scripts has installed on their computer.
44
+
45
+The OS specific files for the new build system are located in the `${GOOS}`
46
+directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When
47
+the kernel or system library updates, modify the Dockerfile at
48
+`${GOOS}/Dockerfile` to checkout the new release of the source.
49
+
50
+To build all the files under the new build system, you must be on an amd64/Linux
51
+system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
52
+then generate all of the files for all of the GOOS/GOARCH pairs in the new build
53
+system. Running `mkall.sh -n` shows the commands that will be run.
54
+
55
+Requirements: bash, perl, go, docker
56
+
57
+## Component files
58
+
59
+This section describes the various files used in the code generation process.
60
+It also contains instructions on how to modify these files to add a new
61
+architecture/OS or to add additional syscalls, types, or constants. Note that
62
+if you are using the new build system, the scripts cannot be called normally.
63
+They must be called from within the docker container.
64
+
65
+### asm files
66
+
67
+The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system
68
+call dispatch. There are three entry points:
69
+```
70
+  func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
71
+  func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
72
+  func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
73
+```
74
+The first and second are the standard ones; they differ only in how many
75
+arguments can be passed to the kernel. The third is for low-level use by the
76
+ForkExec wrapper. Unlike the first two, it does not call into the scheduler to
77
+let it know that a system call is running.
78
+
79
+When porting Go to an new architecture/OS, this file must be implemented for
80
+each GOOS/GOARCH pair.
81
+
82
+### mksysnum
83
+
84
+Mksysnum is a script located at `${GOOS}/mksysnum.pl` (or `mksysnum_${GOOS}.pl`
85
+for the old system). This script takes in a list of header files containing the
86
+syscall number declarations and parses them to produce the corresponding list of
87
+Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
88
+constants.
89
+
90
+Adding new syscall numbers is mostly done by running the build on a sufficiently
91
+new installation of the target OS (or updating the source checkouts for the
92
+new build system). However, depending on the OS, you make need to update the
93
+parsing in mksysnum.
94
+
95
+### mksyscall.pl
96
+
97
+The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
98
+hand-written Go files which implement system calls (for unix, the specific OS,
99
+or the specific OS/Architecture pair respectively) that need special handling
100
+and list `//sys` comments giving prototypes for ones that can be generated.
101
+
102
+The mksyscall.pl script takes the `//sys` and `//sysnb` comments and converts
103
+them into syscalls. This requires the name of the prototype in the comment to
104
+match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
105
+prototype can be exported (capitalized) or not.
106
+
107
+Adding a new syscall often just requires adding a new `//sys` function prototype
108
+with the desired arguments and a capitalized name so it is exported. However, if
109
+you want the interface to the syscall to be different, often one will make an
110
+unexported `//sys` prototype, an then write a custom wrapper in
111
+`syscall_${GOOS}.go`.
112
+
113
+### types files
114
+
115
+For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or
116
+`types_${GOOS}.go` on the old system). This file includes standard C headers and
117
+creates Go type aliases to the corresponding C types. The file is then fed
118
+through godef to get the Go compatible definitions. Finally, the generated code
119
+is fed though mkpost.go to format the code correctly and remove any hidden or
120
+private identifiers. This cleaned-up code is written to
121
+`ztypes_${GOOS}_${GOARCH}.go`.
122
+
123
+The hardest part about preparing this file is figuring out which headers to
124
+include and which symbols need to be `#define`d to get the actual data
125
+structures that pass through to the kernel system calls. Some C libraries
126
+preset alternate versions for binary compatibility and translate them on the
127
+way in and out of system calls, but there is almost always a `#define` that can
128
+get the real ones.
129
+See `types_darwin.go` and `linux/types.go` for examples.
130
+
131
+To add a new type, add in the necessary include statement at the top of the
132
+file (if it is not already there) and add in a type alias line. Note that if
133
+your type is significantly different on different architectures, you may need
134
+some `#if/#elif` macros in your include statements.
135
+
136
+### mkerrors.sh
137
+
138
+This script is used to generate the system's various constants. This doesn't
139
+just include the error numbers and error strings, but also the signal numbers
140
+an a wide variety of miscellaneous constants. The constants come from the list
141
+of include files in the `includes_${uname}` variable. A regex then picks out
142
+the desired `#define` statements, and generates the corresponding Go constants.
143
+The error numbers and strings are generated from `#include <errno.h>`, and the
144
+signal numbers and strings are generated from `#include <signal.h>`. All of
145
+these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program,
146
+`_errors.c`, which prints out all the constants.
147
+
148
+To add a constant, add the header that includes it to the appropriate variable.
149
+Then, edit the regex (if necessary) to match the desired constant. Avoid making
150
+the regex too broad to avoid matching unintended constants.
151
+
152
+
153
+## Generated files
154
+
155
+### `zerror_${GOOS}_${GOARCH}.go`
156
+
157
+A file containing all of the system's generated error numbers, error strings,
158
+signal numbers, and constants. Generated by `mkerrors.sh` (see above).
159
+
160
+### `zsyscall_${GOOS}_${GOARCH}.go`
161
+
162
+A file containing all the generated syscalls for a specific GOOS and GOARCH.
163
+Generated by `mksyscall.pl` (see above).
164
+
165
+### `zsysnum_${GOOS}_${GOARCH}.go`
166
+
167
+A list of numeric constants for all the syscall number of the specific GOOS
168
+and GOARCH. Generated by mksysnum (see above).
169
+
170
+### `ztypes_${GOOS}_${GOARCH}.go`
171
+
172
+A file containing Go types for passing into (or returning from) syscalls.
173
+Generated by godefs and the types file (see above).

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_darwin_386.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for 386, Darwin
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_darwin_amd64.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, Darwin
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 30
- 0
vendor/src/golang.org/x/sys/unix/asm_darwin_arm.s Ver fichero

@@ -0,0 +1,30 @@
1
+// Copyright 2015 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
+// +build !gccgo
6
+// +build arm,darwin
7
+
8
+#include "textflag.h"
9
+
10
+//
11
+// System call support for ARM, Darwin
12
+//
13
+
14
+// Just jump to package syscall's implementation for all these functions.
15
+// The runtime may know about them.
16
+
17
+TEXT	·Syscall(SB),NOSPLIT,$0-28
18
+	B	syscall·Syscall(SB)
19
+
20
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
21
+	B	syscall·Syscall6(SB)
22
+
23
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
24
+	B	syscall·Syscall9(SB)
25
+
26
+TEXT	·RawSyscall(SB),NOSPLIT,$0-28
27
+	B	syscall·RawSyscall(SB)
28
+
29
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
30
+	B	syscall·RawSyscall6(SB)

+ 30
- 0
vendor/src/golang.org/x/sys/unix/asm_darwin_arm64.s Ver fichero

@@ -0,0 +1,30 @@
1
+// Copyright 2015 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
+// +build !gccgo
6
+// +build arm64,darwin
7
+
8
+#include "textflag.h"
9
+
10
+//
11
+// System call support for AMD64, Darwin
12
+//
13
+
14
+// Just jump to package syscall's implementation for all these functions.
15
+// The runtime may know about them.
16
+
17
+TEXT	·Syscall(SB),NOSPLIT,$0-56
18
+	B	syscall·Syscall(SB)
19
+
20
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
21
+	B	syscall·Syscall6(SB)
22
+
23
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
24
+	B	syscall·Syscall9(SB)
25
+
26
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
27
+	B	syscall·RawSyscall(SB)
28
+
29
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
30
+	B	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_dragonfly_amd64.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, DragonFly
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-64
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-88
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-112
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-64
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-88
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_freebsd_386.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for 386, FreeBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_freebsd_amd64.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, FreeBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_freebsd_arm.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2012 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for ARM, FreeBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	B	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	B	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	B	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-28
26
+	B	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	B	syscall·RawSyscall6(SB)

+ 35
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_386.s Ver fichero

@@ -0,0 +1,35 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System calls for 386, Linux
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
23
+	JMP	syscall·RawSyscall(SB)
24
+
25
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
26
+	JMP	syscall·RawSyscall6(SB)
27
+
28
+TEXT ·socketcall(SB),NOSPLIT,$0-36
29
+	JMP	syscall·socketcall(SB)
30
+
31
+TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
32
+	JMP	syscall·rawsocketcall(SB)
33
+
34
+TEXT ·seek(SB),NOSPLIT,$0-28
35
+	JMP	syscall·seek(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_amd64.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System calls for AMD64, Linux
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
23
+	JMP	syscall·RawSyscall(SB)
24
+
25
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
26
+	JMP	syscall·RawSyscall6(SB)
27
+
28
+TEXT ·gettimeofday(SB),NOSPLIT,$0-16
29
+	JMP	syscall·gettimeofday(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_arm.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System calls for arm, Linux
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	B	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	B	syscall·Syscall6(SB)
21
+
22
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
23
+	B	syscall·RawSyscall(SB)
24
+
25
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
26
+	B	syscall·RawSyscall6(SB)
27
+
28
+TEXT ·seek(SB),NOSPLIT,$0-32
29
+	B	syscall·seek(SB)

+ 24
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_arm64.s Ver fichero

@@ -0,0 +1,24 @@
1
+// Copyright 2015 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
+// +build linux
6
+// +build arm64
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+// Just jump to package syscall's implementation for all these functions.
12
+// The runtime may know about them.
13
+
14
+TEXT	·Syscall(SB),NOSPLIT,$0-56
15
+	B	syscall·Syscall(SB)
16
+
17
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
18
+	B	syscall·Syscall6(SB)
19
+
20
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
21
+	B	syscall·RawSyscall(SB)
22
+
23
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
24
+	B	syscall·RawSyscall6(SB)

+ 28
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_mips64x.s Ver fichero

@@ -0,0 +1,28 @@
1
+// Copyright 2015 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
+// +build linux
6
+// +build mips64 mips64le
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+//
12
+// System calls for mips64, Linux
13
+//
14
+
15
+// Just jump to package syscall's implementation for all these functions.
16
+// The runtime may know about them.
17
+
18
+TEXT	·Syscall(SB),NOSPLIT,$0-56
19
+	JMP	syscall·Syscall(SB)
20
+
21
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
22
+	JMP	syscall·Syscall6(SB)
23
+
24
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
25
+	JMP	syscall·RawSyscall(SB)
26
+
27
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
28
+	JMP	syscall·RawSyscall6(SB)

+ 31
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_mipsx.s Ver fichero

@@ -0,0 +1,31 @@
1
+// Copyright 2016 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
+// +build linux
6
+// +build mips mipsle
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+//
12
+// System calls for mips, Linux
13
+//
14
+
15
+// Just jump to package syscall's implementation for all these functions.
16
+// The runtime may know about them.
17
+
18
+TEXT	·Syscall(SB),NOSPLIT,$0-28
19
+	JMP syscall·Syscall(SB)
20
+
21
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
22
+	JMP syscall·Syscall6(SB)
23
+
24
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
25
+	JMP syscall·Syscall9(SB)
26
+
27
+TEXT	·RawSyscall(SB),NOSPLIT,$0-28
28
+	JMP syscall·RawSyscall(SB)
29
+
30
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
31
+	JMP syscall·RawSyscall6(SB)

+ 28
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_ppc64x.s Ver fichero

@@ -0,0 +1,28 @@
1
+// Copyright 2014 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
+// +build linux
6
+// +build ppc64 ppc64le
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+//
12
+// System calls for ppc64, Linux
13
+//
14
+
15
+// Just jump to package syscall's implementation for all these functions.
16
+// The runtime may know about them.
17
+
18
+TEXT	·Syscall(SB),NOSPLIT,$0-56
19
+	BR	syscall·Syscall(SB)
20
+
21
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
22
+	BR	syscall·Syscall6(SB)
23
+
24
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
25
+	BR	syscall·RawSyscall(SB)
26
+
27
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
28
+	BR	syscall·RawSyscall6(SB)

+ 28
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_s390x.s Ver fichero

@@ -0,0 +1,28 @@
1
+// Copyright 2016 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
+// +build s390x
6
+// +build linux
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+//
12
+// System calls for s390x, Linux
13
+//
14
+
15
+// Just jump to package syscall's implementation for all these functions.
16
+// The runtime may know about them.
17
+
18
+TEXT ·Syscall(SB),NOSPLIT,$0-56
19
+	BR	syscall·Syscall(SB)
20
+
21
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
22
+	BR	syscall·Syscall6(SB)
23
+
24
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
25
+	BR	syscall·RawSyscall(SB)
26
+
27
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
28
+	BR	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_netbsd_386.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for 386, NetBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_netbsd_amd64.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, NetBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_netbsd_arm.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2013 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for ARM, NetBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	B	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	B	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	B	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-28
26
+	B	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	B	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_openbsd_386.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for 386, OpenBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_openbsd_amd64.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2009 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, OpenBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_openbsd_arm.s Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2017 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for ARM, OpenBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	B	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	B	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	B	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-28
26
+	B	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	B	syscall·RawSyscall6(SB)

+ 17
- 0
vendor/src/golang.org/x/sys/unix/asm_solaris_amd64.s Ver fichero

@@ -0,0 +1,17 @@
1
+// Copyright 2014 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
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
11
+//
12
+
13
+TEXT ·sysvicall6(SB),NOSPLIT,$0-88
14
+	JMP	syscall·sysvicall6(SB)
15
+
16
+TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88
17
+	JMP	syscall·rawSysvicall6(SB)

+ 35
- 0
vendor/src/golang.org/x/sys/unix/bluetooth_linux.go Ver fichero

@@ -0,0 +1,35 @@
1
+// Copyright 2016 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
+// Bluetooth sockets and messages
6
+
7
+package unix
8
+
9
+// Bluetooth Protocols
10
+const (
11
+	BTPROTO_L2CAP  = 0
12
+	BTPROTO_HCI    = 1
13
+	BTPROTO_SCO    = 2
14
+	BTPROTO_RFCOMM = 3
15
+	BTPROTO_BNEP   = 4
16
+	BTPROTO_CMTP   = 5
17
+	BTPROTO_HIDP   = 6
18
+	BTPROTO_AVDTP  = 7
19
+)
20
+
21
+const (
22
+	HCI_CHANNEL_RAW     = 0
23
+	HCI_CHANNEL_USER    = 1
24
+	HCI_CHANNEL_MONITOR = 2
25
+	HCI_CHANNEL_CONTROL = 3
26
+)
27
+
28
+// Socketoption Level
29
+const (
30
+	SOL_BLUETOOTH = 0x112
31
+	SOL_HCI       = 0x0
32
+	SOL_L2CAP     = 0x6
33
+	SOL_RFCOMM    = 0x12
34
+	SOL_SCO       = 0x11
35
+)

+ 195
- 0
vendor/src/golang.org/x/sys/unix/cap_freebsd.go Ver fichero

@@ -0,0 +1,195 @@
1
+// Copyright 2017 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
+// +build freebsd
6
+
7
+package unix
8
+
9
+import (
10
+	errorspkg "errors"
11
+	"fmt"
12
+)
13
+
14
+// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
15
+
16
+const (
17
+	// This is the version of CapRights this package understands. See C implementation for parallels.
18
+	capRightsGoVersion = CAP_RIGHTS_VERSION_00
19
+	capArSizeMin       = CAP_RIGHTS_VERSION_00 + 2
20
+	capArSizeMax       = capRightsGoVersion + 2
21
+)
22
+
23
+var (
24
+	bit2idx = []int{
25
+		-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1,
26
+		4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
27
+	}
28
+)
29
+
30
+func capidxbit(right uint64) int {
31
+	return int((right >> 57) & 0x1f)
32
+}
33
+
34
+func rightToIndex(right uint64) (int, error) {
35
+	idx := capidxbit(right)
36
+	if idx < 0 || idx >= len(bit2idx) {
37
+		return -2, fmt.Errorf("index for right 0x%x out of range", right)
38
+	}
39
+	return bit2idx[idx], nil
40
+}
41
+
42
+func caprver(right uint64) int {
43
+	return int(right >> 62)
44
+}
45
+
46
+func capver(rights *CapRights) int {
47
+	return caprver(rights.Rights[0])
48
+}
49
+
50
+func caparsize(rights *CapRights) int {
51
+	return capver(rights) + 2
52
+}
53
+
54
+// CapRightsSet sets the permissions in setrights in rights.
55
+func CapRightsSet(rights *CapRights, setrights []uint64) error {
56
+	// This is essentially a copy of cap_rights_vset()
57
+	if capver(rights) != CAP_RIGHTS_VERSION_00 {
58
+		return fmt.Errorf("bad rights version %d", capver(rights))
59
+	}
60
+
61
+	n := caparsize(rights)
62
+	if n < capArSizeMin || n > capArSizeMax {
63
+		return errorspkg.New("bad rights size")
64
+	}
65
+
66
+	for _, right := range setrights {
67
+		if caprver(right) != CAP_RIGHTS_VERSION_00 {
68
+			return errorspkg.New("bad right version")
69
+		}
70
+		i, err := rightToIndex(right)
71
+		if err != nil {
72
+			return err
73
+		}
74
+		if i >= n {
75
+			return errorspkg.New("index overflow")
76
+		}
77
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
78
+			return errorspkg.New("index mismatch")
79
+		}
80
+		rights.Rights[i] |= right
81
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
82
+			return errorspkg.New("index mismatch (after assign)")
83
+		}
84
+	}
85
+
86
+	return nil
87
+}
88
+
89
+// CapRightsClear clears the permissions in clearrights from rights.
90
+func CapRightsClear(rights *CapRights, clearrights []uint64) error {
91
+	// This is essentially a copy of cap_rights_vclear()
92
+	if capver(rights) != CAP_RIGHTS_VERSION_00 {
93
+		return fmt.Errorf("bad rights version %d", capver(rights))
94
+	}
95
+
96
+	n := caparsize(rights)
97
+	if n < capArSizeMin || n > capArSizeMax {
98
+		return errorspkg.New("bad rights size")
99
+	}
100
+
101
+	for _, right := range clearrights {
102
+		if caprver(right) != CAP_RIGHTS_VERSION_00 {
103
+			return errorspkg.New("bad right version")
104
+		}
105
+		i, err := rightToIndex(right)
106
+		if err != nil {
107
+			return err
108
+		}
109
+		if i >= n {
110
+			return errorspkg.New("index overflow")
111
+		}
112
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
113
+			return errorspkg.New("index mismatch")
114
+		}
115
+		rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
116
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
117
+			return errorspkg.New("index mismatch (after assign)")
118
+		}
119
+	}
120
+
121
+	return nil
122
+}
123
+
124
+// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
125
+func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
126
+	// This is essentially a copy of cap_rights_is_vset()
127
+	if capver(rights) != CAP_RIGHTS_VERSION_00 {
128
+		return false, fmt.Errorf("bad rights version %d", capver(rights))
129
+	}
130
+
131
+	n := caparsize(rights)
132
+	if n < capArSizeMin || n > capArSizeMax {
133
+		return false, errorspkg.New("bad rights size")
134
+	}
135
+
136
+	for _, right := range setrights {
137
+		if caprver(right) != CAP_RIGHTS_VERSION_00 {
138
+			return false, errorspkg.New("bad right version")
139
+		}
140
+		i, err := rightToIndex(right)
141
+		if err != nil {
142
+			return false, err
143
+		}
144
+		if i >= n {
145
+			return false, errorspkg.New("index overflow")
146
+		}
147
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
148
+			return false, errorspkg.New("index mismatch")
149
+		}
150
+		if (rights.Rights[i] & right) != right {
151
+			return false, nil
152
+		}
153
+	}
154
+
155
+	return true, nil
156
+}
157
+
158
+func capright(idx uint64, bit uint64) uint64 {
159
+	return ((1 << (57 + idx)) | bit)
160
+}
161
+
162
+// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
163
+// See man cap_rights_init(3) and rights(4).
164
+func CapRightsInit(rights []uint64) (*CapRights, error) {
165
+	var r CapRights
166
+	r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0)
167
+	r.Rights[1] = capright(1, 0)
168
+
169
+	err := CapRightsSet(&r, rights)
170
+	if err != nil {
171
+		return nil, err
172
+	}
173
+	return &r, nil
174
+}
175
+
176
+// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
177
+// The capability rights on fd can never be increased by CapRightsLimit.
178
+// See man cap_rights_limit(2) and rights(4).
179
+func CapRightsLimit(fd uintptr, rights *CapRights) error {
180
+	return capRightsLimit(int(fd), rights)
181
+}
182
+
183
+// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
184
+// See man cap_rights_get(3) and rights(4).
185
+func CapRightsGet(fd uintptr) (*CapRights, error) {
186
+	r, err := CapRightsInit(nil)
187
+	if err != nil {
188
+		return nil, err
189
+	}
190
+	err = capRightsGet(capRightsGoVersion, int(fd), r)
191
+	if err != nil {
192
+		return nil, err
193
+	}
194
+	return r, nil
195
+}

+ 13
- 0
vendor/src/golang.org/x/sys/unix/constants.go Ver fichero

@@ -0,0 +1,13 @@
1
+// Copyright 2015 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
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+package unix
8
+
9
+const (
10
+	R_OK = 0x4
11
+	W_OK = 0x2
12
+	X_OK = 0x1
13
+)

+ 136
- 0
vendor/src/golang.org/x/sys/unix/creds_test.go Ver fichero

@@ -0,0 +1,136 @@
1
+// Copyright 2012 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
+// +build linux
6
+
7
+package unix_test
8
+
9
+import (
10
+	"bytes"
11
+	"net"
12
+	"os"
13
+	"syscall"
14
+	"testing"
15
+
16
+	"golang.org/x/sys/unix"
17
+)
18
+
19
+// TestSCMCredentials tests the sending and receiving of credentials
20
+// (PID, UID, GID) in an ancillary message between two UNIX
21
+// sockets. The SO_PASSCRED socket option is enabled on the sending
22
+// socket for this to work.
23
+func TestSCMCredentials(t *testing.T) {
24
+	socketTypeTests := []struct {
25
+		socketType int
26
+		dataLen    int
27
+	}{
28
+		{
29
+			unix.SOCK_STREAM,
30
+			1,
31
+		}, {
32
+			unix.SOCK_DGRAM,
33
+			0,
34
+		},
35
+	}
36
+
37
+	for _, tt := range socketTypeTests {
38
+		fds, err := unix.Socketpair(unix.AF_LOCAL, tt.socketType, 0)
39
+		if err != nil {
40
+			t.Fatalf("Socketpair: %v", err)
41
+		}
42
+		defer unix.Close(fds[0])
43
+		defer unix.Close(fds[1])
44
+
45
+		err = unix.SetsockoptInt(fds[0], unix.SOL_SOCKET, unix.SO_PASSCRED, 1)
46
+		if err != nil {
47
+			t.Fatalf("SetsockoptInt: %v", err)
48
+		}
49
+
50
+		srvFile := os.NewFile(uintptr(fds[0]), "server")
51
+		defer srvFile.Close()
52
+		srv, err := net.FileConn(srvFile)
53
+		if err != nil {
54
+			t.Errorf("FileConn: %v", err)
55
+			return
56
+		}
57
+		defer srv.Close()
58
+
59
+		cliFile := os.NewFile(uintptr(fds[1]), "client")
60
+		defer cliFile.Close()
61
+		cli, err := net.FileConn(cliFile)
62
+		if err != nil {
63
+			t.Errorf("FileConn: %v", err)
64
+			return
65
+		}
66
+		defer cli.Close()
67
+
68
+		var ucred unix.Ucred
69
+		if os.Getuid() != 0 {
70
+			ucred.Pid = int32(os.Getpid())
71
+			ucred.Uid = 0
72
+			ucred.Gid = 0
73
+			oob := unix.UnixCredentials(&ucred)
74
+			_, _, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil)
75
+			if op, ok := err.(*net.OpError); ok {
76
+				err = op.Err
77
+			}
78
+			if sys, ok := err.(*os.SyscallError); ok {
79
+				err = sys.Err
80
+			}
81
+			if err != syscall.EPERM {
82
+				t.Fatalf("WriteMsgUnix failed with %v, want EPERM", err)
83
+			}
84
+		}
85
+
86
+		ucred.Pid = int32(os.Getpid())
87
+		ucred.Uid = uint32(os.Getuid())
88
+		ucred.Gid = uint32(os.Getgid())
89
+		oob := unix.UnixCredentials(&ucred)
90
+
91
+		// On SOCK_STREAM, this is internally going to send a dummy byte
92
+		n, oobn, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil)
93
+		if err != nil {
94
+			t.Fatalf("WriteMsgUnix: %v", err)
95
+		}
96
+		if n != 0 {
97
+			t.Fatalf("WriteMsgUnix n = %d, want 0", n)
98
+		}
99
+		if oobn != len(oob) {
100
+			t.Fatalf("WriteMsgUnix oobn = %d, want %d", oobn, len(oob))
101
+		}
102
+
103
+		oob2 := make([]byte, 10*len(oob))
104
+		n, oobn2, flags, _, err := srv.(*net.UnixConn).ReadMsgUnix(nil, oob2)
105
+		if err != nil {
106
+			t.Fatalf("ReadMsgUnix: %v", err)
107
+		}
108
+		if flags != 0 {
109
+			t.Fatalf("ReadMsgUnix flags = 0x%x, want 0", flags)
110
+		}
111
+		if n != tt.dataLen {
112
+			t.Fatalf("ReadMsgUnix n = %d, want %d", n, tt.dataLen)
113
+		}
114
+		if oobn2 != oobn {
115
+			// without SO_PASSCRED set on the socket, ReadMsgUnix will
116
+			// return zero oob bytes
117
+			t.Fatalf("ReadMsgUnix oobn = %d, want %d", oobn2, oobn)
118
+		}
119
+		oob2 = oob2[:oobn2]
120
+		if !bytes.Equal(oob, oob2) {
121
+			t.Fatal("ReadMsgUnix oob bytes don't match")
122
+		}
123
+
124
+		scm, err := unix.ParseSocketControlMessage(oob2)
125
+		if err != nil {
126
+			t.Fatalf("ParseSocketControlMessage: %v", err)
127
+		}
128
+		newUcred, err := unix.ParseUnixCredentials(&scm[0])
129
+		if err != nil {
130
+			t.Fatalf("ParseUnixCredentials: %v", err)
131
+		}
132
+		if *newUcred != ucred {
133
+			t.Fatalf("ParseUnixCredentials = %+v, want %+v", newUcred, ucred)
134
+		}
135
+	}
136
+}

+ 24
- 0
vendor/src/golang.org/x/sys/unix/dev_darwin.go Ver fichero

@@ -0,0 +1,24 @@
1
+// Copyright 2017 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
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in Darwin's sys/types.h header.
7
+
8
+package unix
9
+
10
+// Major returns the major component of a Darwin device number.
11
+func Major(dev uint64) uint32 {
12
+	return uint32((dev >> 24) & 0xff)
13
+}
14
+
15
+// Minor returns the minor component of a Darwin device number.
16
+func Minor(dev uint64) uint32 {
17
+	return uint32(dev & 0xffffff)
18
+}
19
+
20
+// Mkdev returns a Darwin device number generated from the given major and minor
21
+// components.
22
+func Mkdev(major, minor uint32) uint64 {
23
+	return (uint64(major) << 24) | uint64(minor)
24
+}

+ 51
- 0
vendor/src/golang.org/x/sys/unix/dev_darwin_test.go Ver fichero

@@ -0,0 +1,51 @@
1
+// Copyright 2017 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
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// Most of the device major/minor numbers on Darwin are
23
+		// dynamically generated by devfs. These are some well-known
24
+		// static numbers.
25
+		{"/dev/ttyp0", 4, 0},
26
+		{"/dev/ttys0", 4, 48},
27
+		{"/dev/ptyp0", 5, 0},
28
+		{"/dev/ptyr0", 5, 32},
29
+	}
30
+	for _, tc := range testCases {
31
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
32
+			var stat unix.Stat_t
33
+			err := unix.Stat(tc.path, &stat)
34
+			if err != nil {
35
+				t.Errorf("failed to stat device: %v", err)
36
+				return
37
+			}
38
+
39
+			dev := uint64(stat.Rdev)
40
+			if unix.Major(dev) != tc.major {
41
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
42
+			}
43
+			if unix.Minor(dev) != tc.minor {
44
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
45
+			}
46
+			if unix.Mkdev(tc.major, tc.minor) != dev {
47
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
48
+			}
49
+		})
50
+	}
51
+}

+ 30
- 0
vendor/src/golang.org/x/sys/unix/dev_dragonfly.go Ver fichero

@@ -0,0 +1,30 @@
1
+// Copyright 2017 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
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in Dragonfly's sys/types.h header.
7
+//
8
+// The information below is extracted and adapted from sys/types.h:
9
+//
10
+// Minor gives a cookie instead of an index since in order to avoid changing the
11
+// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
12
+// devices that don't use them.
13
+
14
+package unix
15
+
16
+// Major returns the major component of a DragonFlyBSD device number.
17
+func Major(dev uint64) uint32 {
18
+	return uint32((dev >> 8) & 0xff)
19
+}
20
+
21
+// Minor returns the minor component of a DragonFlyBSD device number.
22
+func Minor(dev uint64) uint32 {
23
+	return uint32(dev & 0xffff00ff)
24
+}
25
+
26
+// Mkdev returns a DragonFlyBSD device number generated from the given major and
27
+// minor components.
28
+func Mkdev(major, minor uint32) uint64 {
29
+	return (uint64(major) << 8) | uint64(minor)
30
+}

+ 50
- 0
vendor/src/golang.org/x/sys/unix/dev_dragonfly_test.go Ver fichero

@@ -0,0 +1,50 @@
1
+// Copyright 2017 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
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// Minor is a cookie instead of an index on DragonFlyBSD
23
+		{"/dev/null", 10, 0x00000002},
24
+		{"/dev/random", 10, 0x00000003},
25
+		{"/dev/urandom", 10, 0x00000004},
26
+		{"/dev/zero", 10, 0x0000000c},
27
+		{"/dev/bpf", 15, 0xffff00ff},
28
+	}
29
+	for _, tc := range testCases {
30
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
31
+			var stat unix.Stat_t
32
+			err := unix.Stat(tc.path, &stat)
33
+			if err != nil {
34
+				t.Errorf("failed to stat device: %v", err)
35
+				return
36
+			}
37
+
38
+			dev := uint64(stat.Rdev)
39
+			if unix.Major(dev) != tc.major {
40
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
41
+			}
42
+			if unix.Minor(dev) != tc.minor {
43
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
44
+			}
45
+			if unix.Mkdev(tc.major, tc.minor) != dev {
46
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
47
+			}
48
+		})
49
+	}
50
+}

+ 30
- 0
vendor/src/golang.org/x/sys/unix/dev_freebsd.go Ver fichero

@@ -0,0 +1,30 @@
1
+// Copyright 2017 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
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in FreeBSD's sys/types.h header.
7
+//
8
+// The information below is extracted and adapted from sys/types.h:
9
+//
10
+// Minor gives a cookie instead of an index since in order to avoid changing the
11
+// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
12
+// devices that don't use them.
13
+
14
+package unix
15
+
16
+// Major returns the major component of a FreeBSD device number.
17
+func Major(dev uint64) uint32 {
18
+	return uint32((dev >> 8) & 0xff)
19
+}
20
+
21
+// Minor returns the minor component of a FreeBSD device number.
22
+func Minor(dev uint64) uint32 {
23
+	return uint32(dev & 0xffff00ff)
24
+}
25
+
26
+// Mkdev returns a FreeBSD device number generated from the given major and
27
+// minor components.
28
+func Mkdev(major, minor uint32) uint64 {
29
+	return (uint64(major) << 8) | uint64(minor)
30
+}

+ 42
- 0
vendor/src/golang.org/x/sys/unix/dev_linux.go Ver fichero

@@ -0,0 +1,42 @@
1
+// Copyright 2017 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
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used by the Linux kernel and glibc.
7
+//
8
+// The information below is extracted and adapted from bits/sysmacros.h in the
9
+// glibc sources:
10
+//
11
+// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
12
+// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
13
+// number and m is a hex digit of the minor number. This is backward compatible
14
+// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
15
+// backward compatible with the Linux kernel, which for some architectures uses
16
+// 32-bit dev_t, encoded as mmmM MMmm.
17
+
18
+package unix
19
+
20
+// Major returns the major component of a Linux device number.
21
+func Major(dev uint64) uint32 {
22
+	major := uint32((dev & 0x00000000000fff00) >> 8)
23
+	major |= uint32((dev & 0xfffff00000000000) >> 32)
24
+	return major
25
+}
26
+
27
+// Minor returns the minor component of a Linux device number.
28
+func Minor(dev uint64) uint32 {
29
+	minor := uint32((dev & 0x00000000000000ff) >> 0)
30
+	minor |= uint32((dev & 0x00000ffffff00000) >> 12)
31
+	return minor
32
+}
33
+
34
+// Mkdev returns a Linux device number generated from the given major and minor
35
+// components.
36
+func Mkdev(major, minor uint32) uint64 {
37
+	dev := (uint64(major) & 0x00000fff) << 8
38
+	dev |= (uint64(major) & 0xfffff000) << 32
39
+	dev |= (uint64(minor) & 0x000000ff) << 0
40
+	dev |= (uint64(minor) & 0xffffff00) << 12
41
+	return dev
42
+}

+ 53
- 0
vendor/src/golang.org/x/sys/unix/dev_linux_test.go Ver fichero

@@ -0,0 +1,53 @@
1
+// Copyright 2017 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
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// well known major/minor numbers according to
23
+		// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/devices.txt
24
+		{"/dev/null", 1, 3},
25
+		{"/dev/zero", 1, 5},
26
+		{"/dev/random", 1, 8},
27
+		{"/dev/full", 1, 7},
28
+		{"/dev/urandom", 1, 9},
29
+		{"/dev/tty", 5, 0},
30
+	}
31
+	for _, tc := range testCases {
32
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
33
+			var stat unix.Stat_t
34
+			err := unix.Stat(tc.path, &stat)
35
+			if err != nil {
36
+				t.Errorf("failed to stat device: %v", err)
37
+				return
38
+			}
39
+
40
+			dev := uint64(stat.Rdev)
41
+			if unix.Major(dev) != tc.major {
42
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
43
+			}
44
+			if unix.Minor(dev) != tc.minor {
45
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
46
+			}
47
+			if unix.Mkdev(tc.major, tc.minor) != dev {
48
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
49
+			}
50
+		})
51
+
52
+	}
53
+}

+ 29
- 0
vendor/src/golang.org/x/sys/unix/dev_netbsd.go Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2017 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
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in NetBSD's sys/types.h header.
7
+
8
+package unix
9
+
10
+// Major returns the major component of a NetBSD device number.
11
+func Major(dev uint64) uint32 {
12
+	return uint32((dev & 0x000fff00) >> 8)
13
+}
14
+
15
+// Minor returns the minor component of a NetBSD device number.
16
+func Minor(dev uint64) uint32 {
17
+	minor := uint32((dev & 0x000000ff) >> 0)
18
+	minor |= uint32((dev & 0xfff00000) >> 12)
19
+	return minor
20
+}
21
+
22
+// Mkdev returns a NetBSD device number generated from the given major and minor
23
+// components.
24
+func Mkdev(major, minor uint32) uint64 {
25
+	dev := (uint64(major) << 8) & 0x000fff00
26
+	dev |= (uint64(minor) << 12) & 0xfff00000
27
+	dev |= (uint64(minor) << 0) & 0x000000ff
28
+	return dev
29
+}

+ 52
- 0
vendor/src/golang.org/x/sys/unix/dev_netbsd_test.go Ver fichero

@@ -0,0 +1,52 @@
1
+// Copyright 2017 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
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// well known major/minor numbers according to /dev/MAKEDEV on
23
+		// NetBSD 7.0
24
+		{"/dev/null", 2, 2},
25
+		{"/dev/zero", 2, 12},
26
+		{"/dev/ttyp0", 5, 0},
27
+		{"/dev/ttyp1", 5, 1},
28
+		{"/dev/random", 46, 0},
29
+		{"/dev/urandom", 46, 1},
30
+	}
31
+	for _, tc := range testCases {
32
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
33
+			var stat unix.Stat_t
34
+			err := unix.Stat(tc.path, &stat)
35
+			if err != nil {
36
+				t.Errorf("failed to stat device: %v", err)
37
+				return
38
+			}
39
+
40
+			dev := uint64(stat.Rdev)
41
+			if unix.Major(dev) != tc.major {
42
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
43
+			}
44
+			if unix.Minor(dev) != tc.minor {
45
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
46
+			}
47
+			if unix.Mkdev(tc.major, tc.minor) != dev {
48
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
49
+			}
50
+		})
51
+	}
52
+}

+ 29
- 0
vendor/src/golang.org/x/sys/unix/dev_openbsd.go Ver fichero

@@ -0,0 +1,29 @@
1
+// Copyright 2017 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
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in OpenBSD's sys/types.h header.
7
+
8
+package unix
9
+
10
+// Major returns the major component of an OpenBSD device number.
11
+func Major(dev uint64) uint32 {
12
+	return uint32((dev & 0x0000ff00) >> 8)
13
+}
14
+
15
+// Minor returns the minor component of an OpenBSD device number.
16
+func Minor(dev uint64) uint32 {
17
+	minor := uint32((dev & 0x000000ff) >> 0)
18
+	minor |= uint32((dev & 0xffff0000) >> 8)
19
+	return minor
20
+}
21
+
22
+// Mkdev returns an OpenBSD device number generated from the given major and minor
23
+// components.
24
+func Mkdev(major, minor uint32) uint64 {
25
+	dev := (uint64(major) << 8) & 0x0000ff00
26
+	dev |= (uint64(minor) << 8) & 0xffff0000
27
+	dev |= (uint64(minor) << 0) & 0x000000ff
28
+	return dev
29
+}

+ 54
- 0
vendor/src/golang.org/x/sys/unix/dev_openbsd_test.go Ver fichero

@@ -0,0 +1,54 @@
1
+// Copyright 2017 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
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// well known major/minor numbers according to /dev/MAKEDEV on
23
+		// OpenBSD 6.0
24
+		{"/dev/null", 2, 2},
25
+		{"/dev/zero", 2, 12},
26
+		{"/dev/ttyp0", 5, 0},
27
+		{"/dev/ttyp1", 5, 1},
28
+		{"/dev/random", 45, 0},
29
+		{"/dev/srandom", 45, 1},
30
+		{"/dev/urandom", 45, 2},
31
+		{"/dev/arandom", 45, 3},
32
+	}
33
+	for _, tc := range testCases {
34
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
35
+			var stat unix.Stat_t
36
+			err := unix.Stat(tc.path, &stat)
37
+			if err != nil {
38
+				t.Errorf("failed to stat device: %v", err)
39
+				return
40
+			}
41
+
42
+			dev := uint64(stat.Rdev)
43
+			if unix.Major(dev) != tc.major {
44
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
45
+			}
46
+			if unix.Minor(dev) != tc.minor {
47
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
48
+			}
49
+			if unix.Mkdev(tc.major, tc.minor) != dev {
50
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
51
+			}
52
+		})
53
+	}
54
+}

+ 51
- 0
vendor/src/golang.org/x/sys/unix/dev_solaris_test.go Ver fichero

@@ -0,0 +1,51 @@
1
+// Copyright 2017 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
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// Well-known major/minor numbers on OpenSolaris according to
23
+		// /etc/name_to_major
24
+		{"/dev/zero", 134, 12},
25
+		{"/dev/null", 134, 2},
26
+		{"/dev/ptyp0", 172, 0},
27
+		{"/dev/ttyp0", 175, 0},
28
+		{"/dev/ttyp1", 175, 1},
29
+	}
30
+	for _, tc := range testCases {
31
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
32
+			var stat unix.Stat_t
33
+			err := unix.Stat(tc.path, &stat)
34
+			if err != nil {
35
+				t.Errorf("failed to stat device: %v", err)
36
+				return
37
+			}
38
+
39
+			dev := uint64(stat.Rdev)
40
+			if unix.Major(dev) != tc.major {
41
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
42
+			}
43
+			if unix.Minor(dev) != tc.minor {
44
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
45
+			}
46
+			if unix.Mkdev(tc.major, tc.minor) != dev {
47
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
48
+			}
49
+		})
50
+	}
51
+}

+ 102
- 0
vendor/src/golang.org/x/sys/unix/dirent.go Ver fichero

@@ -0,0 +1,102 @@
1
+// Copyright 2009 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
+// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
6
+
7
+package unix
8
+
9
+import "unsafe"
10
+
11
+// readInt returns the size-bytes unsigned integer in native byte order at offset off.
12
+func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
13
+	if len(b) < int(off+size) {
14
+		return 0, false
15
+	}
16
+	if isBigEndian {
17
+		return readIntBE(b[off:], size), true
18
+	}
19
+	return readIntLE(b[off:], size), true
20
+}
21
+
22
+func readIntBE(b []byte, size uintptr) uint64 {
23
+	switch size {
24
+	case 1:
25
+		return uint64(b[0])
26
+	case 2:
27
+		_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
28
+		return uint64(b[1]) | uint64(b[0])<<8
29
+	case 4:
30
+		_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
31
+		return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
32
+	case 8:
33
+		_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
34
+		return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
35
+			uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
36
+	default:
37
+		panic("syscall: readInt with unsupported size")
38
+	}
39
+}
40
+
41
+func readIntLE(b []byte, size uintptr) uint64 {
42
+	switch size {
43
+	case 1:
44
+		return uint64(b[0])
45
+	case 2:
46
+		_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
47
+		return uint64(b[0]) | uint64(b[1])<<8
48
+	case 4:
49
+		_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
50
+		return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
51
+	case 8:
52
+		_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
53
+		return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
54
+			uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
55
+	default:
56
+		panic("syscall: readInt with unsupported size")
57
+	}
58
+}
59
+
60
+// ParseDirent parses up to max directory entries in buf,
61
+// appending the names to names. It returns the number of
62
+// bytes consumed from buf, the number of entries added
63
+// to names, and the new names slice.
64
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
65
+	origlen := len(buf)
66
+	count = 0
67
+	for max != 0 && len(buf) > 0 {
68
+		reclen, ok := direntReclen(buf)
69
+		if !ok || reclen > uint64(len(buf)) {
70
+			return origlen, count, names
71
+		}
72
+		rec := buf[:reclen]
73
+		buf = buf[reclen:]
74
+		ino, ok := direntIno(rec)
75
+		if !ok {
76
+			break
77
+		}
78
+		if ino == 0 { // File absent in directory.
79
+			continue
80
+		}
81
+		const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
82
+		namlen, ok := direntNamlen(rec)
83
+		if !ok || namoff+namlen > uint64(len(rec)) {
84
+			break
85
+		}
86
+		name := rec[namoff : namoff+namlen]
87
+		for i, c := range name {
88
+			if c == 0 {
89
+				name = name[:i]
90
+				break
91
+			}
92
+		}
93
+		// Check for useless names before allocating a string.
94
+		if string(name) == "." || string(name) == ".." {
95
+			continue
96
+		}
97
+		max--
98
+		count++
99
+		names = append(names, string(name))
100
+	}
101
+	return origlen - len(buf), count, names
102
+}

+ 9
- 0
vendor/src/golang.org/x/sys/unix/endian_big.go Ver fichero

@@ -0,0 +1,9 @@
1
+// Copyright 2016 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
+// +build ppc64 s390x mips mips64
6
+
7
+package unix
8
+
9
+const isBigEndian = true

+ 9
- 0
vendor/src/golang.org/x/sys/unix/endian_little.go Ver fichero

@@ -0,0 +1,9 @@
1
+// Copyright 2016 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
+// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le
6
+
7
+package unix
8
+
9
+const isBigEndian = false

+ 27
- 0
vendor/src/golang.org/x/sys/unix/env_unix.go Ver fichero

@@ -0,0 +1,27 @@
1
+// Copyright 2010 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
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+// Unix environment variables.
8
+
9
+package unix
10
+
11
+import "syscall"
12
+
13
+func Getenv(key string) (value string, found bool) {
14
+	return syscall.Getenv(key)
15
+}
16
+
17
+func Setenv(key, value string) error {
18
+	return syscall.Setenv(key, value)
19
+}
20
+
21
+func Clearenv() {
22
+	syscall.Clearenv()
23
+}
24
+
25
+func Environ() []string {
26
+	return syscall.Environ()
27
+}

+ 14
- 0
vendor/src/golang.org/x/sys/unix/env_unset.go Ver fichero

@@ -0,0 +1,14 @@
1
+// Copyright 2014 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
+// +build go1.4
6
+
7
+package unix
8
+
9
+import "syscall"
10
+
11
+func Unsetenv(key string) error {
12
+	// This was added in Go 1.4.
13
+	return syscall.Unsetenv(key)
14
+}

+ 227
- 0
vendor/src/golang.org/x/sys/unix/errors_freebsd_386.go Ver fichero

@@ -0,0 +1,227 @@
1
+// Copyright 2017 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
+// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
6
+// them here for backwards compatibility.
7
+
8
+package unix
9
+
10
+const (
11
+	IFF_SMART                         = 0x20
12
+	IFT_1822                          = 0x2
13
+	IFT_A12MPPSWITCH                  = 0x82
14
+	IFT_AAL2                          = 0xbb
15
+	IFT_AAL5                          = 0x31
16
+	IFT_ADSL                          = 0x5e
17
+	IFT_AFLANE8023                    = 0x3b
18
+	IFT_AFLANE8025                    = 0x3c
19
+	IFT_ARAP                          = 0x58
20
+	IFT_ARCNET                        = 0x23
21
+	IFT_ARCNETPLUS                    = 0x24
22
+	IFT_ASYNC                         = 0x54
23
+	IFT_ATM                           = 0x25
24
+	IFT_ATMDXI                        = 0x69
25
+	IFT_ATMFUNI                       = 0x6a
26
+	IFT_ATMIMA                        = 0x6b
27
+	IFT_ATMLOGICAL                    = 0x50
28
+	IFT_ATMRADIO                      = 0xbd
29
+	IFT_ATMSUBINTERFACE               = 0x86
30
+	IFT_ATMVCIENDPT                   = 0xc2
31
+	IFT_ATMVIRTUAL                    = 0x95
32
+	IFT_BGPPOLICYACCOUNTING           = 0xa2
33
+	IFT_BSC                           = 0x53
34
+	IFT_CCTEMUL                       = 0x3d
35
+	IFT_CEPT                          = 0x13
36
+	IFT_CES                           = 0x85
37
+	IFT_CHANNEL                       = 0x46
38
+	IFT_CNR                           = 0x55
39
+	IFT_COFFEE                        = 0x84
40
+	IFT_COMPOSITELINK                 = 0x9b
41
+	IFT_DCN                           = 0x8d
42
+	IFT_DIGITALPOWERLINE              = 0x8a
43
+	IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
44
+	IFT_DLSW                          = 0x4a
45
+	IFT_DOCSCABLEDOWNSTREAM           = 0x80
46
+	IFT_DOCSCABLEMACLAYER             = 0x7f
47
+	IFT_DOCSCABLEUPSTREAM             = 0x81
48
+	IFT_DS0                           = 0x51
49
+	IFT_DS0BUNDLE                     = 0x52
50
+	IFT_DS1FDL                        = 0xaa
51
+	IFT_DS3                           = 0x1e
52
+	IFT_DTM                           = 0x8c
53
+	IFT_DVBASILN                      = 0xac
54
+	IFT_DVBASIOUT                     = 0xad
55
+	IFT_DVBRCCDOWNSTREAM              = 0x93
56
+	IFT_DVBRCCMACLAYER                = 0x92
57
+	IFT_DVBRCCUPSTREAM                = 0x94
58
+	IFT_ENC                           = 0xf4
59
+	IFT_EON                           = 0x19
60
+	IFT_EPLRS                         = 0x57
61
+	IFT_ESCON                         = 0x49
62
+	IFT_ETHER                         = 0x6
63
+	IFT_FAITH                         = 0xf2
64
+	IFT_FAST                          = 0x7d
65
+	IFT_FASTETHER                     = 0x3e
66
+	IFT_FASTETHERFX                   = 0x45
67
+	IFT_FDDI                          = 0xf
68
+	IFT_FIBRECHANNEL                  = 0x38
69
+	IFT_FRAMERELAYINTERCONNECT        = 0x3a
70
+	IFT_FRAMERELAYMPI                 = 0x5c
71
+	IFT_FRDLCIENDPT                   = 0xc1
72
+	IFT_FRELAY                        = 0x20
73
+	IFT_FRELAYDCE                     = 0x2c
74
+	IFT_FRF16MFRBUNDLE                = 0xa3
75
+	IFT_FRFORWARD                     = 0x9e
76
+	IFT_G703AT2MB                     = 0x43
77
+	IFT_G703AT64K                     = 0x42
78
+	IFT_GIF                           = 0xf0
79
+	IFT_GIGABITETHERNET               = 0x75
80
+	IFT_GR303IDT                      = 0xb2
81
+	IFT_GR303RDT                      = 0xb1
82
+	IFT_H323GATEKEEPER                = 0xa4
83
+	IFT_H323PROXY                     = 0xa5
84
+	IFT_HDH1822                       = 0x3
85
+	IFT_HDLC                          = 0x76
86
+	IFT_HDSL2                         = 0xa8
87
+	IFT_HIPERLAN2                     = 0xb7
88
+	IFT_HIPPI                         = 0x2f
89
+	IFT_HIPPIINTERFACE                = 0x39
90
+	IFT_HOSTPAD                       = 0x5a
91
+	IFT_HSSI                          = 0x2e
92
+	IFT_HY                            = 0xe
93
+	IFT_IBM370PARCHAN                 = 0x48
94
+	IFT_IDSL                          = 0x9a
95
+	IFT_IEEE80211                     = 0x47
96
+	IFT_IEEE80212                     = 0x37
97
+	IFT_IEEE8023ADLAG                 = 0xa1
98
+	IFT_IFGSN                         = 0x91
99
+	IFT_IMT                           = 0xbe
100
+	IFT_INTERLEAVE                    = 0x7c
101
+	IFT_IP                            = 0x7e
102
+	IFT_IPFORWARD                     = 0x8e
103
+	IFT_IPOVERATM                     = 0x72
104
+	IFT_IPOVERCDLC                    = 0x6d
105
+	IFT_IPOVERCLAW                    = 0x6e
106
+	IFT_IPSWITCH                      = 0x4e
107
+	IFT_IPXIP                         = 0xf9
108
+	IFT_ISDN                          = 0x3f
109
+	IFT_ISDNBASIC                     = 0x14
110
+	IFT_ISDNPRIMARY                   = 0x15
111
+	IFT_ISDNS                         = 0x4b
112
+	IFT_ISDNU                         = 0x4c
113
+	IFT_ISO88022LLC                   = 0x29
114
+	IFT_ISO88023                      = 0x7
115
+	IFT_ISO88024                      = 0x8
116
+	IFT_ISO88025                      = 0x9
117
+	IFT_ISO88025CRFPINT               = 0x62
118
+	IFT_ISO88025DTR                   = 0x56
119
+	IFT_ISO88025FIBER                 = 0x73
120
+	IFT_ISO88026                      = 0xa
121
+	IFT_ISUP                          = 0xb3
122
+	IFT_L3IPXVLAN                     = 0x89
123
+	IFT_LAPB                          = 0x10
124
+	IFT_LAPD                          = 0x4d
125
+	IFT_LAPF                          = 0x77
126
+	IFT_LOCALTALK                     = 0x2a
127
+	IFT_LOOP                          = 0x18
128
+	IFT_MEDIAMAILOVERIP               = 0x8b
129
+	IFT_MFSIGLINK                     = 0xa7
130
+	IFT_MIOX25                        = 0x26
131
+	IFT_MODEM                         = 0x30
132
+	IFT_MPC                           = 0x71
133
+	IFT_MPLS                          = 0xa6
134
+	IFT_MPLSTUNNEL                    = 0x96
135
+	IFT_MSDSL                         = 0x8f
136
+	IFT_MVL                           = 0xbf
137
+	IFT_MYRINET                       = 0x63
138
+	IFT_NFAS                          = 0xaf
139
+	IFT_NSIP                          = 0x1b
140
+	IFT_OPTICALCHANNEL                = 0xc3
141
+	IFT_OPTICALTRANSPORT              = 0xc4
142
+	IFT_OTHER                         = 0x1
143
+	IFT_P10                           = 0xc
144
+	IFT_P80                           = 0xd
145
+	IFT_PARA                          = 0x22
146
+	IFT_PFLOG                         = 0xf6
147
+	IFT_PFSYNC                        = 0xf7
148
+	IFT_PLC                           = 0xae
149
+	IFT_POS                           = 0xab
150
+	IFT_PPPMULTILINKBUNDLE            = 0x6c
151
+	IFT_PROPBWAP2MP                   = 0xb8
152
+	IFT_PROPCNLS                      = 0x59
153
+	IFT_PROPDOCSWIRELESSDOWNSTREAM    = 0xb5
154
+	IFT_PROPDOCSWIRELESSMACLAYER      = 0xb4
155
+	IFT_PROPDOCSWIRELESSUPSTREAM      = 0xb6
156
+	IFT_PROPMUX                       = 0x36
157
+	IFT_PROPWIRELESSP2P               = 0x9d
158
+	IFT_PTPSERIAL                     = 0x16
159
+	IFT_PVC                           = 0xf1
160
+	IFT_QLLC                          = 0x44
161
+	IFT_RADIOMAC                      = 0xbc
162
+	IFT_RADSL                         = 0x5f
163
+	IFT_REACHDSL                      = 0xc0
164
+	IFT_RFC1483                       = 0x9f
165
+	IFT_RS232                         = 0x21
166
+	IFT_RSRB                          = 0x4f
167
+	IFT_SDLC                          = 0x11
168
+	IFT_SDSL                          = 0x60
169
+	IFT_SHDSL                         = 0xa9
170
+	IFT_SIP                           = 0x1f
171
+	IFT_SLIP                          = 0x1c
172
+	IFT_SMDSDXI                       = 0x2b
173
+	IFT_SMDSICIP                      = 0x34
174
+	IFT_SONET                         = 0x27
175
+	IFT_SONETOVERHEADCHANNEL          = 0xb9
176
+	IFT_SONETPATH                     = 0x32
177
+	IFT_SONETVT                       = 0x33
178
+	IFT_SRP                           = 0x97
179
+	IFT_SS7SIGLINK                    = 0x9c
180
+	IFT_STACKTOSTACK                  = 0x6f
181
+	IFT_STARLAN                       = 0xb
182
+	IFT_STF                           = 0xd7
183
+	IFT_T1                            = 0x12
184
+	IFT_TDLC                          = 0x74
185
+	IFT_TERMPAD                       = 0x5b
186
+	IFT_TR008                         = 0xb0
187
+	IFT_TRANSPHDLC                    = 0x7b
188
+	IFT_TUNNEL                        = 0x83
189
+	IFT_ULTRA                         = 0x1d
190
+	IFT_USB                           = 0xa0
191
+	IFT_V11                           = 0x40
192
+	IFT_V35                           = 0x2d
193
+	IFT_V36                           = 0x41
194
+	IFT_V37                           = 0x78
195
+	IFT_VDSL                          = 0x61
196
+	IFT_VIRTUALIPADDRESS              = 0x70
197
+	IFT_VOICEEM                       = 0x64
198
+	IFT_VOICEENCAP                    = 0x67
199
+	IFT_VOICEFXO                      = 0x65
200
+	IFT_VOICEFXS                      = 0x66
201
+	IFT_VOICEOVERATM                  = 0x98
202
+	IFT_VOICEOVERFRAMERELAY           = 0x99
203
+	IFT_VOICEOVERIP                   = 0x68
204
+	IFT_X213                          = 0x5d
205
+	IFT_X25                           = 0x5
206
+	IFT_X25DDN                        = 0x4
207
+	IFT_X25HUNTGROUP                  = 0x7a
208
+	IFT_X25MLP                        = 0x79
209
+	IFT_X25PLE                        = 0x28
210
+	IFT_XETHER                        = 0x1a
211
+	IPPROTO_MAXID                     = 0x34
212
+	IPV6_FAITH                        = 0x1d
213
+	IP_FAITH                          = 0x16
214
+	MAP_NORESERVE                     = 0x40
215
+	MAP_RENAME                        = 0x20
216
+	NET_RT_MAXID                      = 0x6
217
+	RTF_PRCLONING                     = 0x10000
218
+	RTM_OLDADD                        = 0x9
219
+	RTM_OLDDEL                        = 0xa
220
+	SIOCADDRT                         = 0x8030720a
221
+	SIOCALIFADDR                      = 0x8118691b
222
+	SIOCDELRT                         = 0x8030720b
223
+	SIOCDLIFADDR                      = 0x8118691d
224
+	SIOCGLIFADDR                      = 0xc118691c
225
+	SIOCGLIFPHYADDR                   = 0xc118694b
226
+	SIOCSLIFPHYADDR                   = 0x8118694a
227
+)

+ 227
- 0
vendor/src/golang.org/x/sys/unix/errors_freebsd_amd64.go Ver fichero

@@ -0,0 +1,227 @@
1
+// Copyright 2017 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
+// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
6
+// them here for backwards compatibility.
7
+
8
+package unix
9
+
10
+const (
11
+	IFF_SMART                         = 0x20
12
+	IFT_1822                          = 0x2
13
+	IFT_A12MPPSWITCH                  = 0x82
14
+	IFT_AAL2                          = 0xbb
15
+	IFT_AAL5                          = 0x31
16
+	IFT_ADSL                          = 0x5e
17
+	IFT_AFLANE8023                    = 0x3b
18
+	IFT_AFLANE8025                    = 0x3c
19
+	IFT_ARAP                          = 0x58
20
+	IFT_ARCNET                        = 0x23
21
+	IFT_ARCNETPLUS                    = 0x24
22
+	IFT_ASYNC                         = 0x54
23
+	IFT_ATM                           = 0x25
24
+	IFT_ATMDXI                        = 0x69
25
+	IFT_ATMFUNI                       = 0x6a
26
+	IFT_ATMIMA                        = 0x6b
27
+	IFT_ATMLOGICAL                    = 0x50
28
+	IFT_ATMRADIO                      = 0xbd
29
+	IFT_ATMSUBINTERFACE               = 0x86
30
+	IFT_ATMVCIENDPT                   = 0xc2
31
+	IFT_ATMVIRTUAL                    = 0x95
32
+	IFT_BGPPOLICYACCOUNTING           = 0xa2
33
+	IFT_BSC                           = 0x53
34
+	IFT_CCTEMUL                       = 0x3d
35
+	IFT_CEPT                          = 0x13
36
+	IFT_CES                           = 0x85
37
+	IFT_CHANNEL                       = 0x46
38
+	IFT_CNR                           = 0x55
39
+	IFT_COFFEE                        = 0x84
40
+	IFT_COMPOSITELINK                 = 0x9b
41
+	IFT_DCN                           = 0x8d
42
+	IFT_DIGITALPOWERLINE              = 0x8a
43
+	IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
44
+	IFT_DLSW                          = 0x4a
45
+	IFT_DOCSCABLEDOWNSTREAM           = 0x80
46
+	IFT_DOCSCABLEMACLAYER             = 0x7f
47
+	IFT_DOCSCABLEUPSTREAM             = 0x81
48
+	IFT_DS0                           = 0x51
49
+	IFT_DS0BUNDLE                     = 0x52
50
+	IFT_DS1FDL                        = 0xaa
51
+	IFT_DS3                           = 0x1e
52
+	IFT_DTM                           = 0x8c
53
+	IFT_DVBASILN                      = 0xac
54
+	IFT_DVBASIOUT                     = 0xad
55
+	IFT_DVBRCCDOWNSTREAM              = 0x93
56
+	IFT_DVBRCCMACLAYER                = 0x92
57
+	IFT_DVBRCCUPSTREAM                = 0x94
58
+	IFT_ENC                           = 0xf4
59
+	IFT_EON                           = 0x19
60
+	IFT_EPLRS                         = 0x57
61
+	IFT_ESCON                         = 0x49
62
+	IFT_ETHER                         = 0x6
63
+	IFT_FAITH                         = 0xf2
64
+	IFT_FAST                          = 0x7d
65
+	IFT_FASTETHER                     = 0x3e
66
+	IFT_FASTETHERFX                   = 0x45
67
+	IFT_FDDI                          = 0xf
68
+	IFT_FIBRECHANNEL                  = 0x38
69
+	IFT_FRAMERELAYINTERCONNECT        = 0x3a
70
+	IFT_FRAMERELAYMPI                 = 0x5c
71
+	IFT_FRDLCIENDPT                   = 0xc1
72
+	IFT_FRELAY                        = 0x20
73
+	IFT_FRELAYDCE                     = 0x2c
74
+	IFT_FRF16MFRBUNDLE                = 0xa3
75
+	IFT_FRFORWARD                     = 0x9e
76
+	IFT_G703AT2MB                     = 0x43
77
+	IFT_G703AT64K                     = 0x42
78
+	IFT_GIF                           = 0xf0
79
+	IFT_GIGABITETHERNET               = 0x75
80
+	IFT_GR303IDT                      = 0xb2
81
+	IFT_GR303RDT                      = 0xb1
82
+	IFT_H323GATEKEEPER                = 0xa4
83
+	IFT_H323PROXY                     = 0xa5
84
+	IFT_HDH1822                       = 0x3
85
+	IFT_HDLC                          = 0x76
86
+	IFT_HDSL2                         = 0xa8
87
+	IFT_HIPERLAN2                     = 0xb7
88
+	IFT_HIPPI                         = 0x2f
89
+	IFT_HIPPIINTERFACE                = 0x39
90
+	IFT_HOSTPAD                       = 0x5a
91
+	IFT_HSSI                          = 0x2e
92
+	IFT_HY                            = 0xe
93
+	IFT_IBM370PARCHAN                 = 0x48
94
+	IFT_IDSL                          = 0x9a
95
+	IFT_IEEE80211                     = 0x47
96
+	IFT_IEEE80212                     = 0x37
97
+	IFT_IEEE8023ADLAG                 = 0xa1
98
+	IFT_IFGSN                         = 0x91
99
+	IFT_IMT                           = 0xbe
100
+	IFT_INTERLEAVE                    = 0x7c
101
+	IFT_IP                            = 0x7e
102
+	IFT_IPFORWARD                     = 0x8e
103
+	IFT_IPOVERATM                     = 0x72
104
+	IFT_IPOVERCDLC                    = 0x6d
105
+	IFT_IPOVERCLAW                    = 0x6e
106
+	IFT_IPSWITCH                      = 0x4e
107
+	IFT_IPXIP                         = 0xf9
108
+	IFT_ISDN                          = 0x3f
109
+	IFT_ISDNBASIC                     = 0x14
110
+	IFT_ISDNPRIMARY                   = 0x15
111
+	IFT_ISDNS                         = 0x4b
112
+	IFT_ISDNU                         = 0x4c
113
+	IFT_ISO88022LLC                   = 0x29
114
+	IFT_ISO88023                      = 0x7
115
+	IFT_ISO88024                      = 0x8
116
+	IFT_ISO88025                      = 0x9
117
+	IFT_ISO88025CRFPINT               = 0x62
118
+	IFT_ISO88025DTR                   = 0x56
119
+	IFT_ISO88025FIBER                 = 0x73
120
+	IFT_ISO88026                      = 0xa
121
+	IFT_ISUP                          = 0xb3
122
+	IFT_L3IPXVLAN                     = 0x89
123
+	IFT_LAPB                          = 0x10
124
+	IFT_LAPD                          = 0x4d
125
+	IFT_LAPF                          = 0x77
126
+	IFT_LOCALTALK                     = 0x2a
127
+	IFT_LOOP                          = 0x18
128
+	IFT_MEDIAMAILOVERIP               = 0x8b
129
+	IFT_MFSIGLINK                     = 0xa7
130
+	IFT_MIOX25                        = 0x26
131
+	IFT_MODEM                         = 0x30
132
+	IFT_MPC                           = 0x71
133
+	IFT_MPLS                          = 0xa6
134
+	IFT_MPLSTUNNEL                    = 0x96
135
+	IFT_MSDSL                         = 0x8f
136
+	IFT_MVL                           = 0xbf
137
+	IFT_MYRINET                       = 0x63
138
+	IFT_NFAS                          = 0xaf
139
+	IFT_NSIP                          = 0x1b
140
+	IFT_OPTICALCHANNEL                = 0xc3
141
+	IFT_OPTICALTRANSPORT              = 0xc4
142
+	IFT_OTHER                         = 0x1
143
+	IFT_P10                           = 0xc
144
+	IFT_P80                           = 0xd
145
+	IFT_PARA                          = 0x22
146
+	IFT_PFLOG                         = 0xf6
147
+	IFT_PFSYNC                        = 0xf7
148
+	IFT_PLC                           = 0xae
149
+	IFT_POS                           = 0xab
150
+	IFT_PPPMULTILINKBUNDLE            = 0x6c
151
+	IFT_PROPBWAP2MP                   = 0xb8
152
+	IFT_PROPCNLS                      = 0x59
153
+	IFT_PROPDOCSWIRELESSDOWNSTREAM    = 0xb5
154
+	IFT_PROPDOCSWIRELESSMACLAYER      = 0xb4
155
+	IFT_PROPDOCSWIRELESSUPSTREAM      = 0xb6
156
+	IFT_PROPMUX                       = 0x36
157
+	IFT_PROPWIRELESSP2P               = 0x9d
158
+	IFT_PTPSERIAL                     = 0x16
159
+	IFT_PVC                           = 0xf1
160
+	IFT_QLLC                          = 0x44
161
+	IFT_RADIOMAC                      = 0xbc
162
+	IFT_RADSL                         = 0x5f
163
+	IFT_REACHDSL                      = 0xc0
164
+	IFT_RFC1483                       = 0x9f
165
+	IFT_RS232                         = 0x21
166
+	IFT_RSRB                          = 0x4f
167
+	IFT_SDLC                          = 0x11
168
+	IFT_SDSL                          = 0x60
169
+	IFT_SHDSL                         = 0xa9
170
+	IFT_SIP                           = 0x1f
171
+	IFT_SLIP                          = 0x1c
172
+	IFT_SMDSDXI                       = 0x2b
173
+	IFT_SMDSICIP                      = 0x34
174
+	IFT_SONET                         = 0x27
175
+	IFT_SONETOVERHEADCHANNEL          = 0xb9
176
+	IFT_SONETPATH                     = 0x32
177
+	IFT_SONETVT                       = 0x33
178
+	IFT_SRP                           = 0x97
179
+	IFT_SS7SIGLINK                    = 0x9c
180
+	IFT_STACKTOSTACK                  = 0x6f
181
+	IFT_STARLAN                       = 0xb
182
+	IFT_STF                           = 0xd7
183
+	IFT_T1                            = 0x12
184
+	IFT_TDLC                          = 0x74
185
+	IFT_TERMPAD                       = 0x5b
186
+	IFT_TR008                         = 0xb0
187
+	IFT_TRANSPHDLC                    = 0x7b
188
+	IFT_TUNNEL                        = 0x83
189
+	IFT_ULTRA                         = 0x1d
190
+	IFT_USB                           = 0xa0
191
+	IFT_V11                           = 0x40
192
+	IFT_V35                           = 0x2d
193
+	IFT_V36                           = 0x41
194
+	IFT_V37                           = 0x78
195
+	IFT_VDSL                          = 0x61
196
+	IFT_VIRTUALIPADDRESS              = 0x70
197
+	IFT_VOICEEM                       = 0x64
198
+	IFT_VOICEENCAP                    = 0x67
199
+	IFT_VOICEFXO                      = 0x65
200
+	IFT_VOICEFXS                      = 0x66
201
+	IFT_VOICEOVERATM                  = 0x98
202
+	IFT_VOICEOVERFRAMERELAY           = 0x99
203
+	IFT_VOICEOVERIP                   = 0x68
204
+	IFT_X213                          = 0x5d
205
+	IFT_X25                           = 0x5
206
+	IFT_X25DDN                        = 0x4
207
+	IFT_X25HUNTGROUP                  = 0x7a
208
+	IFT_X25MLP                        = 0x79
209
+	IFT_X25PLE                        = 0x28
210
+	IFT_XETHER                        = 0x1a
211
+	IPPROTO_MAXID                     = 0x34
212
+	IPV6_FAITH                        = 0x1d
213
+	IP_FAITH                          = 0x16
214
+	MAP_NORESERVE                     = 0x40
215
+	MAP_RENAME                        = 0x20
216
+	NET_RT_MAXID                      = 0x6
217
+	RTF_PRCLONING                     = 0x10000
218
+	RTM_OLDADD                        = 0x9
219
+	RTM_OLDDEL                        = 0xa
220
+	SIOCADDRT                         = 0x8040720a
221
+	SIOCALIFADDR                      = 0x8118691b
222
+	SIOCDELRT                         = 0x8040720b
223
+	SIOCDLIFADDR                      = 0x8118691d
224
+	SIOCGLIFADDR                      = 0xc118691c
225
+	SIOCGLIFPHYADDR                   = 0xc118694b
226
+	SIOCSLIFPHYADDR                   = 0x8118694a
227
+)

+ 226
- 0
vendor/src/golang.org/x/sys/unix/errors_freebsd_arm.go Ver fichero

@@ -0,0 +1,226 @@
1
+// Copyright 2017 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
+package unix
6
+
7
+const (
8
+	IFT_1822                          = 0x2
9
+	IFT_A12MPPSWITCH                  = 0x82
10
+	IFT_AAL2                          = 0xbb
11
+	IFT_AAL5                          = 0x31
12
+	IFT_ADSL                          = 0x5e
13
+	IFT_AFLANE8023                    = 0x3b
14
+	IFT_AFLANE8025                    = 0x3c
15
+	IFT_ARAP                          = 0x58
16
+	IFT_ARCNET                        = 0x23
17
+	IFT_ARCNETPLUS                    = 0x24
18
+	IFT_ASYNC                         = 0x54
19
+	IFT_ATM                           = 0x25
20
+	IFT_ATMDXI                        = 0x69
21
+	IFT_ATMFUNI                       = 0x6a
22
+	IFT_ATMIMA                        = 0x6b
23
+	IFT_ATMLOGICAL                    = 0x50
24
+	IFT_ATMRADIO                      = 0xbd
25
+	IFT_ATMSUBINTERFACE               = 0x86
26
+	IFT_ATMVCIENDPT                   = 0xc2
27
+	IFT_ATMVIRTUAL                    = 0x95
28
+	IFT_BGPPOLICYACCOUNTING           = 0xa2
29
+	IFT_BSC                           = 0x53
30
+	IFT_CCTEMUL                       = 0x3d
31
+	IFT_CEPT                          = 0x13
32
+	IFT_CES                           = 0x85
33
+	IFT_CHANNEL                       = 0x46
34
+	IFT_CNR                           = 0x55
35
+	IFT_COFFEE                        = 0x84
36
+	IFT_COMPOSITELINK                 = 0x9b
37
+	IFT_DCN                           = 0x8d
38
+	IFT_DIGITALPOWERLINE              = 0x8a
39
+	IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
40
+	IFT_DLSW                          = 0x4a
41
+	IFT_DOCSCABLEDOWNSTREAM           = 0x80
42
+	IFT_DOCSCABLEMACLAYER             = 0x7f
43
+	IFT_DOCSCABLEUPSTREAM             = 0x81
44
+	IFT_DS0                           = 0x51
45
+	IFT_DS0BUNDLE                     = 0x52
46
+	IFT_DS1FDL                        = 0xaa
47
+	IFT_DS3                           = 0x1e
48
+	IFT_DTM                           = 0x8c
49
+	IFT_DVBASILN                      = 0xac
50
+	IFT_DVBASIOUT                     = 0xad
51
+	IFT_DVBRCCDOWNSTREAM              = 0x93
52
+	IFT_DVBRCCMACLAYER                = 0x92
53
+	IFT_DVBRCCUPSTREAM                = 0x94
54
+	IFT_ENC                           = 0xf4
55
+	IFT_EON                           = 0x19
56
+	IFT_EPLRS                         = 0x57
57
+	IFT_ESCON                         = 0x49
58
+	IFT_ETHER                         = 0x6
59
+	IFT_FAST                          = 0x7d
60
+	IFT_FASTETHER                     = 0x3e
61
+	IFT_FASTETHERFX                   = 0x45
62
+	IFT_FDDI                          = 0xf
63
+	IFT_FIBRECHANNEL                  = 0x38
64
+	IFT_FRAMERELAYINTERCONNECT        = 0x3a
65
+	IFT_FRAMERELAYMPI                 = 0x5c
66
+	IFT_FRDLCIENDPT                   = 0xc1
67
+	IFT_FRELAY                        = 0x20
68
+	IFT_FRELAYDCE                     = 0x2c
69
+	IFT_FRF16MFRBUNDLE                = 0xa3
70
+	IFT_FRFORWARD                     = 0x9e
71
+	IFT_G703AT2MB                     = 0x43
72
+	IFT_G703AT64K                     = 0x42
73
+	IFT_GIF                           = 0xf0
74
+	IFT_GIGABITETHERNET               = 0x75
75
+	IFT_GR303IDT                      = 0xb2
76
+	IFT_GR303RDT                      = 0xb1
77
+	IFT_H323GATEKEEPER                = 0xa4
78
+	IFT_H323PROXY                     = 0xa5
79
+	IFT_HDH1822                       = 0x3
80
+	IFT_HDLC                          = 0x76
81
+	IFT_HDSL2                         = 0xa8
82
+	IFT_HIPERLAN2                     = 0xb7
83
+	IFT_HIPPI                         = 0x2f
84
+	IFT_HIPPIINTERFACE                = 0x39
85
+	IFT_HOSTPAD                       = 0x5a
86
+	IFT_HSSI                          = 0x2e
87
+	IFT_HY                            = 0xe
88
+	IFT_IBM370PARCHAN                 = 0x48
89
+	IFT_IDSL                          = 0x9a
90
+	IFT_IEEE80211                     = 0x47
91
+	IFT_IEEE80212                     = 0x37
92
+	IFT_IEEE8023ADLAG                 = 0xa1
93
+	IFT_IFGSN                         = 0x91
94
+	IFT_IMT                           = 0xbe
95
+	IFT_INTERLEAVE                    = 0x7c
96
+	IFT_IP                            = 0x7e
97
+	IFT_IPFORWARD                     = 0x8e
98
+	IFT_IPOVERATM                     = 0x72
99
+	IFT_IPOVERCDLC                    = 0x6d
100
+	IFT_IPOVERCLAW                    = 0x6e
101
+	IFT_IPSWITCH                      = 0x4e
102
+	IFT_ISDN                          = 0x3f
103
+	IFT_ISDNBASIC                     = 0x14
104
+	IFT_ISDNPRIMARY                   = 0x15
105
+	IFT_ISDNS                         = 0x4b
106
+	IFT_ISDNU                         = 0x4c
107
+	IFT_ISO88022LLC                   = 0x29
108
+	IFT_ISO88023                      = 0x7
109
+	IFT_ISO88024                      = 0x8
110
+	IFT_ISO88025                      = 0x9
111
+	IFT_ISO88025CRFPINT               = 0x62
112
+	IFT_ISO88025DTR                   = 0x56
113
+	IFT_ISO88025FIBER                 = 0x73
114
+	IFT_ISO88026                      = 0xa
115
+	IFT_ISUP                          = 0xb3
116
+	IFT_L3IPXVLAN                     = 0x89
117
+	IFT_LAPB                          = 0x10
118
+	IFT_LAPD                          = 0x4d
119
+	IFT_LAPF                          = 0x77
120
+	IFT_LOCALTALK                     = 0x2a
121
+	IFT_LOOP                          = 0x18
122
+	IFT_MEDIAMAILOVERIP               = 0x8b
123
+	IFT_MFSIGLINK                     = 0xa7
124
+	IFT_MIOX25                        = 0x26
125
+	IFT_MODEM                         = 0x30
126
+	IFT_MPC                           = 0x71
127
+	IFT_MPLS                          = 0xa6
128
+	IFT_MPLSTUNNEL                    = 0x96
129
+	IFT_MSDSL                         = 0x8f
130
+	IFT_MVL                           = 0xbf
131
+	IFT_MYRINET                       = 0x63
132
+	IFT_NFAS                          = 0xaf
133
+	IFT_NSIP                          = 0x1b
134
+	IFT_OPTICALCHANNEL                = 0xc3
135
+	IFT_OPTICALTRANSPORT              = 0xc4
136
+	IFT_OTHER                         = 0x1
137
+	IFT_P10                           = 0xc
138
+	IFT_P80                           = 0xd
139
+	IFT_PARA                          = 0x22
140
+	IFT_PFLOG                         = 0xf6
141
+	IFT_PFSYNC                        = 0xf7
142
+	IFT_PLC                           = 0xae
143
+	IFT_POS                           = 0xab
144
+	IFT_PPPMULTILINKBUNDLE            = 0x6c
145
+	IFT_PROPBWAP2MP                   = 0xb8
146
+	IFT_PROPCNLS                      = 0x59
147
+	IFT_PROPDOCSWIRELESSDOWNSTREAM    = 0xb5
148
+	IFT_PROPDOCSWIRELESSMACLAYER      = 0xb4
149
+	IFT_PROPDOCSWIRELESSUPSTREAM      = 0xb6
150
+	IFT_PROPMUX                       = 0x36
151
+	IFT_PROPWIRELESSP2P               = 0x9d
152
+	IFT_PTPSERIAL                     = 0x16
153
+	IFT_PVC                           = 0xf1
154
+	IFT_QLLC                          = 0x44
155
+	IFT_RADIOMAC                      = 0xbc
156
+	IFT_RADSL                         = 0x5f
157
+	IFT_REACHDSL                      = 0xc0
158
+	IFT_RFC1483                       = 0x9f
159
+	IFT_RS232                         = 0x21
160
+	IFT_RSRB                          = 0x4f
161
+	IFT_SDLC                          = 0x11
162
+	IFT_SDSL                          = 0x60
163
+	IFT_SHDSL                         = 0xa9
164
+	IFT_SIP                           = 0x1f
165
+	IFT_SLIP                          = 0x1c
166
+	IFT_SMDSDXI                       = 0x2b
167
+	IFT_SMDSICIP                      = 0x34
168
+	IFT_SONET                         = 0x27
169
+	IFT_SONETOVERHEADCHANNEL          = 0xb9
170
+	IFT_SONETPATH                     = 0x32
171
+	IFT_SONETVT                       = 0x33
172
+	IFT_SRP                           = 0x97
173
+	IFT_SS7SIGLINK                    = 0x9c
174
+	IFT_STACKTOSTACK                  = 0x6f
175
+	IFT_STARLAN                       = 0xb
176
+	IFT_STF                           = 0xd7
177
+	IFT_T1                            = 0x12
178
+	IFT_TDLC                          = 0x74
179
+	IFT_TERMPAD                       = 0x5b
180
+	IFT_TR008                         = 0xb0
181
+	IFT_TRANSPHDLC                    = 0x7b
182
+	IFT_TUNNEL                        = 0x83
183
+	IFT_ULTRA                         = 0x1d
184
+	IFT_USB                           = 0xa0
185
+	IFT_V11                           = 0x40
186
+	IFT_V35                           = 0x2d
187
+	IFT_V36                           = 0x41
188
+	IFT_V37                           = 0x78
189
+	IFT_VDSL                          = 0x61
190
+	IFT_VIRTUALIPADDRESS              = 0x70
191
+	IFT_VOICEEM                       = 0x64
192
+	IFT_VOICEENCAP                    = 0x67
193
+	IFT_VOICEFXO                      = 0x65
194
+	IFT_VOICEFXS                      = 0x66
195
+	IFT_VOICEOVERATM                  = 0x98
196
+	IFT_VOICEOVERFRAMERELAY           = 0x99
197
+	IFT_VOICEOVERIP                   = 0x68
198
+	IFT_X213                          = 0x5d
199
+	IFT_X25                           = 0x5
200
+	IFT_X25DDN                        = 0x4
201
+	IFT_X25HUNTGROUP                  = 0x7a
202
+	IFT_X25MLP                        = 0x79
203
+	IFT_X25PLE                        = 0x28
204
+	IFT_XETHER                        = 0x1a
205
+
206
+	// missing constants on FreeBSD-11.1-RELEASE, copied from old values in ztypes_freebsd_arm.go
207
+	IFF_SMART       = 0x20
208
+	IFT_FAITH       = 0xf2
209
+	IFT_IPXIP       = 0xf9
210
+	IPPROTO_MAXID   = 0x34
211
+	IPV6_FAITH      = 0x1d
212
+	IP_FAITH        = 0x16
213
+	MAP_NORESERVE   = 0x40
214
+	MAP_RENAME      = 0x20
215
+	NET_RT_MAXID    = 0x6
216
+	RTF_PRCLONING   = 0x10000
217
+	RTM_OLDADD      = 0x9
218
+	RTM_OLDDEL      = 0xa
219
+	SIOCADDRT       = 0x8030720a
220
+	SIOCALIFADDR    = 0x8118691b
221
+	SIOCDELRT       = 0x8030720b
222
+	SIOCDLIFADDR    = 0x8118691d
223
+	SIOCGLIFADDR    = 0xc118691c
224
+	SIOCGLIFPHYADDR = 0xc118694b
225
+	SIOCSLIFPHYADDR = 0x8118694a
226
+)

+ 9
- 0
vendor/src/golang.org/x/sys/unix/export_test.go Ver fichero

@@ -0,0 +1,9 @@
1
+// Copyright 2015 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
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+package unix
8
+
9
+var Itoa = itoa

+ 22
- 0
vendor/src/golang.org/x/sys/unix/flock.go Ver fichero

@@ -0,0 +1,22 @@
1
+// Copyright 2014 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
+// +build darwin dragonfly freebsd linux netbsd openbsd
6
+
7
+package unix
8
+
9
+import "unsafe"
10
+
11
+// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
12
+// systems by flock_linux_32bit.go to be SYS_FCNTL64.
13
+var fcntl64Syscall uintptr = SYS_FCNTL
14
+
15
+// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
16
+func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
17
+	_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
18
+	if errno == 0 {
19
+		return nil
20
+	}
21
+	return errno
22
+}

+ 13
- 0
vendor/src/golang.org/x/sys/unix/flock_linux_32bit.go Ver fichero

@@ -0,0 +1,13 @@
1
+// +build linux,386 linux,arm linux,mips linux,mipsle
2
+
3
+// Copyright 2014 The Go Authors. All rights reserved.
4
+// Use of this source code is governed by a BSD-style
5
+// license that can be found in the LICENSE file.
6
+
7
+package unix
8
+
9
+func init() {
10
+	// On 32-bit Linux systems, the fcntl syscall that matches Go's
11
+	// Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
12
+	fcntl64Syscall = SYS_FCNTL64
13
+}

+ 46
- 0
vendor/src/golang.org/x/sys/unix/gccgo.go Ver fichero

@@ -0,0 +1,46 @@
1
+// Copyright 2015 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
+// +build gccgo
6
+
7
+package unix
8
+
9
+import "syscall"
10
+
11
+// We can't use the gc-syntax .s files for gccgo. On the plus side
12
+// much of the functionality can be written directly in Go.
13
+
14
+//extern gccgoRealSyscall
15
+func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
16
+
17
+func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
18
+	syscall.Entersyscall()
19
+	r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
20
+	syscall.Exitsyscall()
21
+	return r, 0, syscall.Errno(errno)
22
+}
23
+
24
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
25
+	syscall.Entersyscall()
26
+	r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
27
+	syscall.Exitsyscall()
28
+	return r, 0, syscall.Errno(errno)
29
+}
30
+
31
+func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
32
+	syscall.Entersyscall()
33
+	r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
34
+	syscall.Exitsyscall()
35
+	return r, 0, syscall.Errno(errno)
36
+}
37
+
38
+func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
39
+	r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
40
+	return r, 0, syscall.Errno(errno)
41
+}
42
+
43
+func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
44
+	r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
45
+	return r, 0, syscall.Errno(errno)
46
+}

+ 41
- 0
vendor/src/golang.org/x/sys/unix/gccgo_c.c Ver fichero

@@ -0,0 +1,41 @@
1
+// Copyright 2015 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
+// +build gccgo
6
+
7
+#include <errno.h>
8
+#include <stdint.h>
9
+#include <unistd.h>
10
+
11
+#define _STRINGIFY2_(x) #x
12
+#define _STRINGIFY_(x) _STRINGIFY2_(x)
13
+#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
14
+
15
+// Call syscall from C code because the gccgo support for calling from
16
+// Go to C does not support varargs functions.
17
+
18
+struct ret {
19
+	uintptr_t r;
20
+	uintptr_t err;
21
+};
22
+
23
+struct ret
24
+gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
25
+{
26
+	struct ret r;
27
+
28
+	errno = 0;
29
+	r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
30
+	r.err = errno;
31
+	return r;
32
+}
33
+
34
+// Define the use function in C so that it is not inlined.
35
+
36
+extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
37
+
38
+void
39
+use(void *p __attribute__ ((unused)))
40
+{
41
+}

+ 20
- 0
vendor/src/golang.org/x/sys/unix/gccgo_linux_amd64.go Ver fichero

@@ -0,0 +1,20 @@
1
+// Copyright 2015 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
+// +build gccgo,linux,amd64
6
+
7
+package unix
8
+
9
+import "syscall"
10
+
11
+//extern gettimeofday
12
+func realGettimeofday(*Timeval, *byte) int32
13
+
14
+func gettimeofday(tv *Timeval) (err syscall.Errno) {
15
+	r := realGettimeofday(tv, nil)
16
+	if r < 0 {
17
+		return syscall.GetErrno()
18
+	}
19
+	return 0
20
+}

+ 51
- 0
vendor/src/golang.org/x/sys/unix/linux/Dockerfile Ver fichero

@@ -0,0 +1,51 @@
1
+FROM ubuntu:16.04
2
+
3
+# Use the most recent ubuntu sources
4
+RUN echo 'deb http://en.archive.ubuntu.com/ubuntu/ artful main universe' >> /etc/apt/sources.list
5
+
6
+# Dependencies to get the git sources and go binaries
7
+RUN apt-get update && apt-get install -y \
8
+        curl \
9
+        git \
10
+    && rm -rf /var/lib/apt/lists/*
11
+
12
+# Get the git sources. If not cached, this takes O(5 minutes).
13
+WORKDIR /git
14
+RUN git config --global advice.detachedHead false
15
+# Linux Kernel: Released 03 Sep 2017
16
+RUN git clone --branch v4.13 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
17
+# GNU C library: Released 02 Aug 2017 (we should try to get a secure way to clone this)
18
+RUN git clone --branch glibc-2.26 --depth 1 git://sourceware.org/git/glibc.git
19
+
20
+# Get Go 1.9.2
21
+ENV GOLANG_VERSION 1.9.2
22
+ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
23
+ENV GOLANG_DOWNLOAD_SHA256 de874549d9a8d8d8062be05808509c09a88a248e77ec14eb77453530829ac02b
24
+
25
+RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
26
+    && echo "$GOLANG_DOWNLOAD_SHA256  golang.tar.gz" | sha256sum -c - \
27
+    && tar -C /usr/local -xzf golang.tar.gz \
28
+    && rm golang.tar.gz
29
+
30
+ENV PATH /usr/local/go/bin:$PATH
31
+
32
+# Linux and Glibc build dependencies
33
+RUN apt-get update && apt-get install -y \
34
+        gawk make python \
35
+        gcc gcc-multilib \
36
+        gettext texinfo \
37
+    && rm -rf /var/lib/apt/lists/*
38
+# Emulator and cross compilers
39
+RUN apt-get update && apt-get install -y \
40
+        qemu \
41
+        gcc-aarch64-linux-gnu       gcc-arm-linux-gnueabi     \
42
+        gcc-mips-linux-gnu          gcc-mips64-linux-gnuabi64 \
43
+        gcc-mips64el-linux-gnuabi64 gcc-mipsel-linux-gnu      \
44
+        gcc-powerpc64-linux-gnu     gcc-powerpc64le-linux-gnu \
45
+        gcc-s390x-linux-gnu         gcc-sparc64-linux-gnu     \
46
+    && rm -rf /var/lib/apt/lists/*
47
+
48
+# Let the scripts know they are in the docker environment
49
+ENV GOLANG_SYS_BUILD docker
50
+WORKDIR /build
51
+ENTRYPOINT ["go", "run", "linux/mkall.go", "/git/linux", "/git/glibc"]

+ 482
- 0
vendor/src/golang.org/x/sys/unix/linux/mkall.go Ver fichero

@@ -0,0 +1,482 @@
1
+// Copyright 2017 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
+// linux/mkall.go - Generates all Linux zsysnum, zsyscall, zerror, and ztype
6
+// files for all 11 linux architectures supported by the go compiler. See
7
+// README.md for more information about the build system.
8
+
9
+// To run it you must have a git checkout of the Linux kernel and glibc. Once
10
+// the appropriate sources are ready, the program is run as:
11
+//     go run linux/mkall.go <linux_dir> <glibc_dir>
12
+
13
+// +build ignore
14
+
15
+package main
16
+
17
+import (
18
+	"bufio"
19
+	"bytes"
20
+	"fmt"
21
+	"io"
22
+	"io/ioutil"
23
+	"os"
24
+	"os/exec"
25
+	"path/filepath"
26
+	"runtime"
27
+	"strings"
28
+	"unicode"
29
+)
30
+
31
+// These will be paths to the appropriate source directories.
32
+var LinuxDir string
33
+var GlibcDir string
34
+
35
+const TempDir = "/tmp"
36
+const IncludeDir = TempDir + "/include" // To hold our C headers
37
+const BuildDir = TempDir + "/build"     // To hold intermediate build files
38
+
39
+const GOOS = "linux"       // Only for Linux targets
40
+const BuildArch = "amd64"  // Must be built on this architecture
41
+const MinKernel = "2.6.23" // https://golang.org/doc/install#requirements
42
+
43
+type target struct {
44
+	GoArch     string // Architecture name according to Go
45
+	LinuxArch  string // Architecture name according to the Linux Kernel
46
+	GNUArch    string // Architecture name according to GNU tools (https://wiki.debian.org/Multiarch/Tuples)
47
+	BigEndian  bool   // Default Little Endian
48
+	SignedChar bool   // Is -fsigned-char needed (default no)
49
+	Bits       int
50
+}
51
+
52
+// List of the 11 Linux targets supported by the go compiler. sparc64 is not
53
+// currently supported, though a port is in progress.
54
+var targets = []target{
55
+	{
56
+		GoArch:    "386",
57
+		LinuxArch: "x86",
58
+		GNUArch:   "i686-linux-gnu", // Note "i686" not "i386"
59
+		Bits:      32,
60
+	},
61
+	{
62
+		GoArch:    "amd64",
63
+		LinuxArch: "x86",
64
+		GNUArch:   "x86_64-linux-gnu",
65
+		Bits:      64,
66
+	},
67
+	{
68
+		GoArch:     "arm64",
69
+		LinuxArch:  "arm64",
70
+		GNUArch:    "aarch64-linux-gnu",
71
+		SignedChar: true,
72
+		Bits:       64,
73
+	},
74
+	{
75
+		GoArch:    "arm",
76
+		LinuxArch: "arm",
77
+		GNUArch:   "arm-linux-gnueabi",
78
+		Bits:      32,
79
+	},
80
+	{
81
+		GoArch:    "mips",
82
+		LinuxArch: "mips",
83
+		GNUArch:   "mips-linux-gnu",
84
+		BigEndian: true,
85
+		Bits:      32,
86
+	},
87
+	{
88
+		GoArch:    "mipsle",
89
+		LinuxArch: "mips",
90
+		GNUArch:   "mipsel-linux-gnu",
91
+		Bits:      32,
92
+	},
93
+	{
94
+		GoArch:    "mips64",
95
+		LinuxArch: "mips",
96
+		GNUArch:   "mips64-linux-gnuabi64",
97
+		BigEndian: true,
98
+		Bits:      64,
99
+	},
100
+	{
101
+		GoArch:    "mips64le",
102
+		LinuxArch: "mips",
103
+		GNUArch:   "mips64el-linux-gnuabi64",
104
+		Bits:      64,
105
+	},
106
+	{
107
+		GoArch:    "ppc64",
108
+		LinuxArch: "powerpc",
109
+		GNUArch:   "powerpc64-linux-gnu",
110
+		BigEndian: true,
111
+		Bits:      64,
112
+	},
113
+	{
114
+		GoArch:    "ppc64le",
115
+		LinuxArch: "powerpc",
116
+		GNUArch:   "powerpc64le-linux-gnu",
117
+		Bits:      64,
118
+	},
119
+	{
120
+		GoArch:     "s390x",
121
+		LinuxArch:  "s390",
122
+		GNUArch:    "s390x-linux-gnu",
123
+		BigEndian:  true,
124
+		SignedChar: true,
125
+		Bits:       64,
126
+	},
127
+	// {
128
+	// 	GoArch:    "sparc64",
129
+	// 	LinuxArch: "sparc",
130
+	// 	GNUArch:   "sparc64-linux-gnu",
131
+	// 	BigEndian: true,
132
+	// 	Bits:      64,
133
+	// },
134
+}
135
+
136
+// ptracePairs is a list of pairs of targets that can, in some cases,
137
+// run each other's binaries.
138
+var ptracePairs = []struct{ a1, a2 string }{
139
+	{"386", "amd64"},
140
+	{"arm", "arm64"},
141
+	{"mips", "mips64"},
142
+	{"mipsle", "mips64le"},
143
+}
144
+
145
+func main() {
146
+	if runtime.GOOS != GOOS || runtime.GOARCH != BuildArch {
147
+		fmt.Printf("Build system has GOOS_GOARCH = %s_%s, need %s_%s\n",
148
+			runtime.GOOS, runtime.GOARCH, GOOS, BuildArch)
149
+		return
150
+	}
151
+
152
+	// Check that we are using the new build system if we should
153
+	if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
154
+		fmt.Println("In the new build system, mkall.go should not be called directly.")
155
+		fmt.Println("See README.md")
156
+		return
157
+	}
158
+
159
+	// Parse the command line options
160
+	if len(os.Args) != 3 {
161
+		fmt.Println("USAGE: go run linux/mkall.go <linux_dir> <glibc_dir>")
162
+		return
163
+	}
164
+	LinuxDir = os.Args[1]
165
+	GlibcDir = os.Args[2]
166
+
167
+	for _, t := range targets {
168
+		fmt.Printf("----- GENERATING: %s -----\n", t.GoArch)
169
+		if err := t.generateFiles(); err != nil {
170
+			fmt.Printf("%v\n***** FAILURE:    %s *****\n\n", err, t.GoArch)
171
+		} else {
172
+			fmt.Printf("----- SUCCESS:    %s -----\n\n", t.GoArch)
173
+		}
174
+	}
175
+
176
+	fmt.Printf("----- GENERATING ptrace pairs -----\n")
177
+	ok := true
178
+	for _, p := range ptracePairs {
179
+		if err := generatePtracePair(p.a1, p.a2); err != nil {
180
+			fmt.Printf("%v\n***** FAILURE: %s/%s *****\n\n", err, p.a1, p.a2)
181
+			ok = false
182
+		}
183
+	}
184
+	if ok {
185
+		fmt.Printf("----- SUCCESS ptrace pairs    -----\n\n")
186
+	}
187
+}
188
+
189
+// Makes an exec.Cmd with Stderr attached to os.Stderr
190
+func makeCommand(name string, args ...string) *exec.Cmd {
191
+	cmd := exec.Command(name, args...)
192
+	cmd.Stderr = os.Stderr
193
+	return cmd
194
+}
195
+
196
+// Runs the command, pipes output to a formatter, pipes that to an output file.
197
+func (t *target) commandFormatOutput(formatter string, outputFile string,
198
+	name string, args ...string) (err error) {
199
+	mainCmd := makeCommand(name, args...)
200
+
201
+	fmtCmd := makeCommand(formatter)
202
+	if formatter == "mkpost" {
203
+		fmtCmd = makeCommand("go", "run", "mkpost.go")
204
+		// Set GOARCH_TARGET so mkpost knows what GOARCH is..
205
+		fmtCmd.Env = append(os.Environ(), "GOARCH_TARGET="+t.GoArch)
206
+		// Set GOARCH to host arch for mkpost, so it can run natively.
207
+		for i, s := range fmtCmd.Env {
208
+			if strings.HasPrefix(s, "GOARCH=") {
209
+				fmtCmd.Env[i] = "GOARCH=" + BuildArch
210
+			}
211
+		}
212
+	}
213
+
214
+	// mainCmd | fmtCmd > outputFile
215
+	if fmtCmd.Stdin, err = mainCmd.StdoutPipe(); err != nil {
216
+		return
217
+	}
218
+	if fmtCmd.Stdout, err = os.Create(outputFile); err != nil {
219
+		return
220
+	}
221
+
222
+	// Make sure the formatter eventually closes
223
+	if err = fmtCmd.Start(); err != nil {
224
+		return
225
+	}
226
+	defer func() {
227
+		fmtErr := fmtCmd.Wait()
228
+		if err == nil {
229
+			err = fmtErr
230
+		}
231
+	}()
232
+
233
+	return mainCmd.Run()
234
+}
235
+
236
+// Generates all the files for a Linux target
237
+func (t *target) generateFiles() error {
238
+	// Setup environment variables
239
+	os.Setenv("GOOS", GOOS)
240
+	os.Setenv("GOARCH", t.GoArch)
241
+
242
+	// Get appropriate compiler and emulator (unless on x86)
243
+	if t.LinuxArch != "x86" {
244
+		// Check/Setup cross compiler
245
+		compiler := t.GNUArch + "-gcc"
246
+		if _, err := exec.LookPath(compiler); err != nil {
247
+			return err
248
+		}
249
+		os.Setenv("CC", compiler)
250
+
251
+		// Check/Setup emulator (usually first component of GNUArch)
252
+		qemuArchName := t.GNUArch[:strings.Index(t.GNUArch, "-")]
253
+		if t.LinuxArch == "powerpc" {
254
+			qemuArchName = t.GoArch
255
+		}
256
+		os.Setenv("GORUN", "qemu-"+qemuArchName)
257
+	} else {
258
+		os.Setenv("CC", "gcc")
259
+	}
260
+
261
+	// Make the include directory and fill it with headers
262
+	if err := os.MkdirAll(IncludeDir, os.ModePerm); err != nil {
263
+		return err
264
+	}
265
+	defer os.RemoveAll(IncludeDir)
266
+	if err := t.makeHeaders(); err != nil {
267
+		return fmt.Errorf("could not make header files: %v", err)
268
+	}
269
+	fmt.Println("header files generated")
270
+
271
+	// Make each of the four files
272
+	if err := t.makeZSysnumFile(); err != nil {
273
+		return fmt.Errorf("could not make zsysnum file: %v", err)
274
+	}
275
+	fmt.Println("zsysnum file generated")
276
+
277
+	if err := t.makeZSyscallFile(); err != nil {
278
+		return fmt.Errorf("could not make zsyscall file: %v", err)
279
+	}
280
+	fmt.Println("zsyscall file generated")
281
+
282
+	if err := t.makeZTypesFile(); err != nil {
283
+		return fmt.Errorf("could not make ztypes file: %v", err)
284
+	}
285
+	fmt.Println("ztypes file generated")
286
+
287
+	if err := t.makeZErrorsFile(); err != nil {
288
+		return fmt.Errorf("could not make zerrors file: %v", err)
289
+	}
290
+	fmt.Println("zerrors file generated")
291
+
292
+	return nil
293
+}
294
+
295
+// Create the Linux and glibc headers in the include directory.
296
+func (t *target) makeHeaders() error {
297
+	// Make the Linux headers we need for this architecture
298
+	linuxMake := makeCommand("make", "headers_install", "ARCH="+t.LinuxArch, "INSTALL_HDR_PATH="+TempDir)
299
+	linuxMake.Dir = LinuxDir
300
+	if err := linuxMake.Run(); err != nil {
301
+		return err
302
+	}
303
+
304
+	// A Temporary build directory for glibc
305
+	if err := os.MkdirAll(BuildDir, os.ModePerm); err != nil {
306
+		return err
307
+	}
308
+	defer os.RemoveAll(BuildDir)
309
+
310
+	// Make the glibc headers we need for this architecture
311
+	confScript := filepath.Join(GlibcDir, "configure")
312
+	glibcConf := makeCommand(confScript, "--prefix="+TempDir, "--host="+t.GNUArch, "--enable-kernel="+MinKernel)
313
+	glibcConf.Dir = BuildDir
314
+	if err := glibcConf.Run(); err != nil {
315
+		return err
316
+	}
317
+	glibcMake := makeCommand("make", "install-headers")
318
+	glibcMake.Dir = BuildDir
319
+	if err := glibcMake.Run(); err != nil {
320
+		return err
321
+	}
322
+	// We only need an empty stubs file
323
+	stubsFile := filepath.Join(IncludeDir, "gnu/stubs.h")
324
+	if file, err := os.Create(stubsFile); err != nil {
325
+		return err
326
+	} else {
327
+		file.Close()
328
+	}
329
+
330
+	return nil
331
+}
332
+
333
+// makes the zsysnum_linux_$GOARCH.go file
334
+func (t *target) makeZSysnumFile() error {
335
+	zsysnumFile := fmt.Sprintf("zsysnum_linux_%s.go", t.GoArch)
336
+	unistdFile := filepath.Join(IncludeDir, "asm/unistd.h")
337
+
338
+	args := append(t.cFlags(), unistdFile)
339
+	return t.commandFormatOutput("gofmt", zsysnumFile, "linux/mksysnum.pl", args...)
340
+}
341
+
342
+// makes the zsyscall_linux_$GOARCH.go file
343
+func (t *target) makeZSyscallFile() error {
344
+	zsyscallFile := fmt.Sprintf("zsyscall_linux_%s.go", t.GoArch)
345
+	// Find the correct architecture syscall file (might end with x.go)
346
+	archSyscallFile := fmt.Sprintf("syscall_linux_%s.go", t.GoArch)
347
+	if _, err := os.Stat(archSyscallFile); os.IsNotExist(err) {
348
+		shortArch := strings.TrimSuffix(t.GoArch, "le")
349
+		archSyscallFile = fmt.Sprintf("syscall_linux_%sx.go", shortArch)
350
+	}
351
+
352
+	args := append(t.mksyscallFlags(), "-tags", "linux,"+t.GoArch,
353
+		"syscall_linux.go", archSyscallFile)
354
+	return t.commandFormatOutput("gofmt", zsyscallFile, "./mksyscall.pl", args...)
355
+}
356
+
357
+// makes the zerrors_linux_$GOARCH.go file
358
+func (t *target) makeZErrorsFile() error {
359
+	zerrorsFile := fmt.Sprintf("zerrors_linux_%s.go", t.GoArch)
360
+
361
+	return t.commandFormatOutput("gofmt", zerrorsFile, "./mkerrors.sh", t.cFlags()...)
362
+}
363
+
364
+// makes the ztypes_linux_$GOARCH.go file
365
+func (t *target) makeZTypesFile() error {
366
+	ztypesFile := fmt.Sprintf("ztypes_linux_%s.go", t.GoArch)
367
+
368
+	args := []string{"tool", "cgo", "-godefs", "--"}
369
+	args = append(args, t.cFlags()...)
370
+	args = append(args, "linux/types.go")
371
+	return t.commandFormatOutput("mkpost", ztypesFile, "go", args...)
372
+}
373
+
374
+// Flags that should be given to gcc and cgo for this target
375
+func (t *target) cFlags() []string {
376
+	// Compile statically to avoid cross-architecture dynamic linking.
377
+	flags := []string{"-Wall", "-Werror", "-static", "-I" + IncludeDir}
378
+
379
+	// Architecture-specific flags
380
+	if t.SignedChar {
381
+		flags = append(flags, "-fsigned-char")
382
+	}
383
+	if t.LinuxArch == "x86" {
384
+		flags = append(flags, fmt.Sprintf("-m%d", t.Bits))
385
+	}
386
+
387
+	return flags
388
+}
389
+
390
+// Flags that should be given to mksyscall for this target
391
+func (t *target) mksyscallFlags() (flags []string) {
392
+	if t.Bits == 32 {
393
+		if t.BigEndian {
394
+			flags = append(flags, "-b32")
395
+		} else {
396
+			flags = append(flags, "-l32")
397
+		}
398
+	}
399
+
400
+	// This flag menas a 64-bit value should use (even, odd)-pair.
401
+	if t.GoArch == "arm" || (t.LinuxArch == "mips" && t.Bits == 32) {
402
+		flags = append(flags, "-arm")
403
+	}
404
+	return
405
+}
406
+
407
+// generatePtracePair takes a pair of GOARCH values that can run each
408
+// other's binaries, such as 386 and amd64. It extracts the PtraceRegs
409
+// type for each one. It writes a new file defining the types
410
+// PtraceRegsArch1 and PtraceRegsArch2 and the corresponding functions
411
+// Ptrace{Get,Set}Regs{arch1,arch2}. This permits debugging the other
412
+// binary on a native system.
413
+func generatePtracePair(arch1, arch2 string) error {
414
+	def1, err := ptraceDef(arch1)
415
+	if err != nil {
416
+		return err
417
+	}
418
+	def2, err := ptraceDef(arch2)
419
+	if err != nil {
420
+		return err
421
+	}
422
+	f, err := os.Create(fmt.Sprintf("zptrace%s_linux.go", arch1))
423
+	if err != nil {
424
+		return err
425
+	}
426
+	buf := bufio.NewWriter(f)
427
+	fmt.Fprintf(buf, "// Code generated by linux/mkall.go generatePtracePair(%s, %s). DO NOT EDIT.\n", arch1, arch2)
428
+	fmt.Fprintf(buf, "\n")
429
+	fmt.Fprintf(buf, "// +build linux\n")
430
+	fmt.Fprintf(buf, "// +build %s %s\n", arch1, arch2)
431
+	fmt.Fprintf(buf, "\n")
432
+	fmt.Fprintf(buf, "package unix\n")
433
+	fmt.Fprintf(buf, "\n")
434
+	fmt.Fprintf(buf, "%s\n", `import "unsafe"`)
435
+	fmt.Fprintf(buf, "\n")
436
+	writeOnePtrace(buf, arch1, def1)
437
+	fmt.Fprintf(buf, "\n")
438
+	writeOnePtrace(buf, arch2, def2)
439
+	if err := buf.Flush(); err != nil {
440
+		return err
441
+	}
442
+	if err := f.Close(); err != nil {
443
+		return err
444
+	}
445
+	return nil
446
+}
447
+
448
+// ptraceDef returns the definition of PtraceRegs for arch.
449
+func ptraceDef(arch string) (string, error) {
450
+	filename := fmt.Sprintf("ztypes_linux_%s.go", arch)
451
+	data, err := ioutil.ReadFile(filename)
452
+	if err != nil {
453
+		return "", fmt.Errorf("reading %s: %v", filename, err)
454
+	}
455
+	start := bytes.Index(data, []byte("type PtraceRegs struct"))
456
+	if start < 0 {
457
+		return "", fmt.Errorf("%s: no definition of PtraceRegs", filename)
458
+	}
459
+	data = data[start:]
460
+	end := bytes.Index(data, []byte("\n}\n"))
461
+	if end < 0 {
462
+		return "", fmt.Errorf("%s: can't find end of PtraceRegs definition", filename)
463
+	}
464
+	return string(data[:end+2]), nil
465
+}
466
+
467
+// writeOnePtrace writes out the ptrace definitions for arch.
468
+func writeOnePtrace(w io.Writer, arch, def string) {
469
+	uarch := string(unicode.ToUpper(rune(arch[0]))) + arch[1:]
470
+	fmt.Fprintf(w, "// PtraceRegs%s is the registers used by %s binaries.\n", uarch, arch)
471
+	fmt.Fprintf(w, "%s\n", strings.Replace(def, "PtraceRegs", "PtraceRegs"+uarch, 1))
472
+	fmt.Fprintf(w, "\n")
473
+	fmt.Fprintf(w, "// PtraceGetRegs%s fetches the registers used by %s binaries.\n", uarch, arch)
474
+	fmt.Fprintf(w, "func PtraceGetRegs%s(pid int, regsout *PtraceRegs%s) error {\n", uarch, uarch)
475
+	fmt.Fprintf(w, "\treturn ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))\n")
476
+	fmt.Fprintf(w, "}\n")
477
+	fmt.Fprintf(w, "\n")
478
+	fmt.Fprintf(w, "// PtraceSetRegs%s sets the registers used by %s binaries.\n", uarch, arch)
479
+	fmt.Fprintf(w, "func PtraceSetRegs%s(pid int, regs *PtraceRegs%s) error {\n", uarch, uarch)
480
+	fmt.Fprintf(w, "\treturn ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))\n")
481
+	fmt.Fprintf(w, "}\n")
482
+}

+ 85
- 0
vendor/src/golang.org/x/sys/unix/linux/mksysnum.pl Ver fichero

@@ -0,0 +1,85 @@
1
+#!/usr/bin/env perl
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+
6
+use strict;
7
+
8
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
9
+	print STDERR "GOARCH or GOOS not defined in environment\n";
10
+	exit 1;
11
+}
12
+
13
+# Check that we are using the new build system if we should
14
+if($ENV{'GOLANG_SYS_BUILD'} ne "docker") {
15
+	print STDERR "In the new build system, mksysnum should not be called directly.\n";
16
+	print STDERR "See README.md\n";
17
+	exit 1;
18
+}
19
+
20
+my $command = "$0 ". join(' ', @ARGV);
21
+
22
+print <<EOF;
23
+// $command
24
+// Code generated by the command above; see README.md. DO NOT EDIT.
25
+
26
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
27
+
28
+package unix
29
+
30
+const(
31
+EOF
32
+
33
+my $offset = 0;
34
+
35
+sub fmt {
36
+	my ($name, $num) = @_;
37
+	if($num > 999){
38
+		# ignore deprecated syscalls that are no longer implemented
39
+		# https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716
40
+		return;
41
+	}
42
+	$name =~ y/a-z/A-Z/;
43
+	$num = $num + $offset;
44
+	print "	SYS_$name = $num;\n";
45
+}
46
+
47
+my $prev;
48
+open(CC, "$ENV{'CC'} -E -dD @ARGV |") || die "can't run $ENV{'CC'}";
49
+while(<CC>){
50
+	if(/^#define __NR_Linux\s+([0-9]+)/){
51
+		# mips/mips64: extract offset
52
+		$offset = $1;
53
+	}
54
+	elsif(/^#define __NR(\w*)_SYSCALL_BASE\s+([0-9]+)/){
55
+		# arm: extract offset
56
+		$offset = $1;
57
+	}
58
+	elsif(/^#define __NR_syscalls\s+/) {
59
+		# ignore redefinitions of __NR_syscalls
60
+	}
61
+	elsif(/^#define __NR_(\w*)Linux_syscalls\s+/) {
62
+		# mips/mips64: ignore definitions about the number of syscalls
63
+	}
64
+	elsif(/^#define __NR_(\w+)\s+([0-9]+)/){
65
+		$prev = $2;
66
+		fmt($1, $2);
67
+	}
68
+	elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){
69
+		$prev = $2;
70
+		fmt($1, $2);
71
+	}
72
+	elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
73
+		fmt($1, $prev+$2)
74
+	}
75
+	elsif(/^#define __NR_(\w+)\s+\(__NR_Linux \+ ([0-9]+)/){
76
+		fmt($1, $2);
77
+	}
78
+	elsif(/^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE \+ ([0-9]+)/){
79
+		fmt($1, $2);
80
+	}
81
+}
82
+
83
+print <<EOF;
84
+)
85
+EOF

+ 595
- 0
vendor/src/golang.org/x/sys/unix/linux/types.go Ver fichero

@@ -0,0 +1,595 @@
1
+// Copyright 2009 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
+// +build ignore
6
+
7
+/*
8
+Input to cgo -godefs.  See README.md
9
+*/
10
+
11
+// +godefs map struct_in_addr [4]byte /* in_addr */
12
+// +godefs map struct_in6_addr [16]byte /* in6_addr */
13
+
14
+package unix
15
+
16
+/*
17
+#define _LARGEFILE_SOURCE
18
+#define _LARGEFILE64_SOURCE
19
+#define _FILE_OFFSET_BITS 64
20
+#define _GNU_SOURCE
21
+
22
+#include <dirent.h>
23
+#include <netinet/in.h>
24
+#include <netinet/tcp.h>
25
+#include <netpacket/packet.h>
26
+#include <poll.h>
27
+#include <signal.h>
28
+#include <stdio.h>
29
+#include <sys/epoll.h>
30
+#include <sys/inotify.h>
31
+#include <sys/ioctl.h>
32
+#include <sys/mman.h>
33
+#include <sys/mount.h>
34
+#include <sys/param.h>
35
+#include <sys/ptrace.h>
36
+#include <sys/resource.h>
37
+#include <sys/select.h>
38
+#include <sys/signal.h>
39
+#include <sys/statfs.h>
40
+#include <sys/sysinfo.h>
41
+#include <sys/time.h>
42
+#include <sys/times.h>
43
+#include <sys/timex.h>
44
+#include <sys/un.h>
45
+#include <sys/user.h>
46
+#include <sys/utsname.h>
47
+#include <sys/wait.h>
48
+#include <linux/filter.h>
49
+#include <linux/keyctl.h>
50
+#include <linux/netlink.h>
51
+#include <linux/perf_event.h>
52
+#include <linux/rtnetlink.h>
53
+#include <linux/icmpv6.h>
54
+#include <asm/termbits.h>
55
+#include <asm/ptrace.h>
56
+#include <time.h>
57
+#include <unistd.h>
58
+#include <ustat.h>
59
+#include <utime.h>
60
+#include <linux/can.h>
61
+#include <linux/if_alg.h>
62
+#include <linux/fs.h>
63
+#include <linux/vm_sockets.h>
64
+#include <linux/random.h>
65
+#include <linux/taskstats.h>
66
+#include <linux/genetlink.h>
67
+
68
+// On mips64, the glibc stat and kernel stat do not agree
69
+#if (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI64)
70
+
71
+// Use the stat defined by the kernel with a few modifications. These are:
72
+//	* The time fields (like st_atime and st_atimensec) use the timespec
73
+//	  struct (like st_atim) for consitancy with the glibc fields.
74
+//	* The padding fields get different names to not break compatibility.
75
+//	* st_blocks is signed, again for compatibility.
76
+struct stat {
77
+	unsigned int		st_dev;
78
+	unsigned int		st_pad1[3]; // Reserved for st_dev expansion
79
+
80
+	unsigned long		st_ino;
81
+
82
+	mode_t			st_mode;
83
+	__u32			st_nlink;
84
+
85
+	uid_t			st_uid;
86
+	gid_t			st_gid;
87
+
88
+	unsigned int		st_rdev;
89
+	unsigned int		st_pad2[3]; // Reserved for st_rdev expansion
90
+
91
+	off_t			st_size;
92
+
93
+	// These are declared as speperate fields in the kernel. Here we use
94
+	// the timespec struct for consistancy with the other stat structs.
95
+	struct timespec		st_atim;
96
+	struct timespec		st_mtim;
97
+	struct timespec		st_ctim;
98
+
99
+	unsigned int		st_blksize;
100
+	unsigned int		st_pad4;
101
+
102
+	long			st_blocks;
103
+};
104
+
105
+// These are needed because we do not include fcntl.h or sys/types.h
106
+#include <linux/fcntl.h>
107
+#include <linux/fadvise.h>
108
+
109
+#else
110
+
111
+// Use the stat defined by glibc
112
+#include <fcntl.h>
113
+#include <sys/types.h>
114
+
115
+#endif
116
+
117
+#ifdef TCSETS2
118
+// On systems that have "struct termios2" use this as type Termios.
119
+typedef struct termios2 termios_t;
120
+#else
121
+typedef struct termios termios_t;
122
+#endif
123
+
124
+enum {
125
+	sizeofPtr = sizeof(void*),
126
+};
127
+
128
+union sockaddr_all {
129
+	struct sockaddr s1;	// this one gets used for fields
130
+	struct sockaddr_in s2;	// these pad it out
131
+	struct sockaddr_in6 s3;
132
+	struct sockaddr_un s4;
133
+	struct sockaddr_ll s5;
134
+	struct sockaddr_nl s6;
135
+};
136
+
137
+struct sockaddr_any {
138
+	struct sockaddr addr;
139
+	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
140
+};
141
+
142
+// copied from /usr/include/bluetooth/hci.h
143
+struct sockaddr_hci {
144
+        sa_family_t     hci_family;
145
+        unsigned short  hci_dev;
146
+        unsigned short  hci_channel;
147
+};;
148
+
149
+// copied from /usr/include/linux/un.h
150
+struct my_sockaddr_un {
151
+	sa_family_t sun_family;
152
+#if defined(__ARM_EABI__) || defined(__powerpc64__)
153
+	// on ARM char is by default unsigned
154
+	signed char sun_path[108];
155
+#else
156
+	char sun_path[108];
157
+#endif
158
+};
159
+
160
+#ifdef __ARM_EABI__
161
+typedef struct user_regs PtraceRegs;
162
+#elif defined(__aarch64__)
163
+typedef struct user_pt_regs PtraceRegs;
164
+#elif defined(__mips__) || defined(__powerpc64__)
165
+typedef struct pt_regs PtraceRegs;
166
+#elif defined(__s390x__)
167
+typedef struct _user_regs_struct PtraceRegs;
168
+#elif defined(__sparc__)
169
+#include <asm/ptrace.h>
170
+typedef struct pt_regs PtraceRegs;
171
+#else
172
+typedef struct user_regs_struct PtraceRegs;
173
+#endif
174
+
175
+#if defined(__s390x__)
176
+typedef struct _user_psw_struct ptracePsw;
177
+typedef struct _user_fpregs_struct ptraceFpregs;
178
+typedef struct _user_per_struct ptracePer;
179
+#else
180
+typedef struct {} ptracePsw;
181
+typedef struct {} ptraceFpregs;
182
+typedef struct {} ptracePer;
183
+#endif
184
+
185
+// The real epoll_event is a union, and godefs doesn't handle it well.
186
+struct my_epoll_event {
187
+	uint32_t events;
188
+#if defined(__ARM_EABI__) || defined(__aarch64__) || (defined(__mips__) && _MIPS_SIM == _ABIO32)
189
+	// padding is not specified in linux/eventpoll.h but added to conform to the
190
+	// alignment requirements of EABI
191
+	int32_t padFd;
192
+#elif defined(__powerpc64__) || defined(__s390x__) || defined(__sparc__)
193
+	int32_t _padFd;
194
+#endif
195
+	int32_t fd;
196
+	int32_t pad;
197
+};
198
+
199
+*/
200
+import "C"
201
+
202
+// Machine characteristics; for internal use.
203
+
204
+const (
205
+	sizeofPtr      = C.sizeofPtr
206
+	sizeofShort    = C.sizeof_short
207
+	sizeofInt      = C.sizeof_int
208
+	sizeofLong     = C.sizeof_long
209
+	sizeofLongLong = C.sizeof_longlong
210
+	PathMax        = C.PATH_MAX
211
+)
212
+
213
+// Basic types
214
+
215
+type (
216
+	_C_short     C.short
217
+	_C_int       C.int
218
+	_C_long      C.long
219
+	_C_long_long C.longlong
220
+)
221
+
222
+// Time
223
+
224
+type Timespec C.struct_timespec
225
+
226
+type Timeval C.struct_timeval
227
+
228
+type Timex C.struct_timex
229
+
230
+type Time_t C.time_t
231
+
232
+type Tms C.struct_tms
233
+
234
+type Utimbuf C.struct_utimbuf
235
+
236
+// Processes
237
+
238
+type Rusage C.struct_rusage
239
+
240
+type Rlimit C.struct_rlimit
241
+
242
+type _Gid_t C.gid_t
243
+
244
+// Files
245
+
246
+type Stat_t C.struct_stat
247
+
248
+type Statfs_t C.struct_statfs
249
+
250
+type Dirent C.struct_dirent
251
+
252
+type Fsid C.fsid_t
253
+
254
+type Flock_t C.struct_flock
255
+
256
+// Filesystem Encryption
257
+
258
+type FscryptPolicy C.struct_fscrypt_policy
259
+
260
+type FscryptKey C.struct_fscrypt_key
261
+
262
+// Structure for Keyctl
263
+
264
+type KeyctlDHParams C.struct_keyctl_dh_params
265
+
266
+// Advice to Fadvise
267
+
268
+const (
269
+	FADV_NORMAL     = C.POSIX_FADV_NORMAL
270
+	FADV_RANDOM     = C.POSIX_FADV_RANDOM
271
+	FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
272
+	FADV_WILLNEED   = C.POSIX_FADV_WILLNEED
273
+	FADV_DONTNEED   = C.POSIX_FADV_DONTNEED
274
+	FADV_NOREUSE    = C.POSIX_FADV_NOREUSE
275
+)
276
+
277
+// Sockets
278
+
279
+type RawSockaddrInet4 C.struct_sockaddr_in
280
+
281
+type RawSockaddrInet6 C.struct_sockaddr_in6
282
+
283
+type RawSockaddrUnix C.struct_my_sockaddr_un
284
+
285
+type RawSockaddrLinklayer C.struct_sockaddr_ll
286
+
287
+type RawSockaddrNetlink C.struct_sockaddr_nl
288
+
289
+type RawSockaddrHCI C.struct_sockaddr_hci
290
+
291
+type RawSockaddrCAN C.struct_sockaddr_can
292
+
293
+type RawSockaddrALG C.struct_sockaddr_alg
294
+
295
+type RawSockaddrVM C.struct_sockaddr_vm
296
+
297
+type RawSockaddr C.struct_sockaddr
298
+
299
+type RawSockaddrAny C.struct_sockaddr_any
300
+
301
+type _Socklen C.socklen_t
302
+
303
+type Linger C.struct_linger
304
+
305
+type Iovec C.struct_iovec
306
+
307
+type IPMreq C.struct_ip_mreq
308
+
309
+type IPMreqn C.struct_ip_mreqn
310
+
311
+type IPv6Mreq C.struct_ipv6_mreq
312
+
313
+type PacketMreq C.struct_packet_mreq
314
+
315
+type Msghdr C.struct_msghdr
316
+
317
+type Cmsghdr C.struct_cmsghdr
318
+
319
+type Inet4Pktinfo C.struct_in_pktinfo
320
+
321
+type Inet6Pktinfo C.struct_in6_pktinfo
322
+
323
+type IPv6MTUInfo C.struct_ip6_mtuinfo
324
+
325
+type ICMPv6Filter C.struct_icmp6_filter
326
+
327
+type Ucred C.struct_ucred
328
+
329
+type TCPInfo C.struct_tcp_info
330
+
331
+const (
332
+	SizeofSockaddrInet4     = C.sizeof_struct_sockaddr_in
333
+	SizeofSockaddrInet6     = C.sizeof_struct_sockaddr_in6
334
+	SizeofSockaddrAny       = C.sizeof_struct_sockaddr_any
335
+	SizeofSockaddrUnix      = C.sizeof_struct_sockaddr_un
336
+	SizeofSockaddrLinklayer = C.sizeof_struct_sockaddr_ll
337
+	SizeofSockaddrNetlink   = C.sizeof_struct_sockaddr_nl
338
+	SizeofSockaddrHCI       = C.sizeof_struct_sockaddr_hci
339
+	SizeofSockaddrCAN       = C.sizeof_struct_sockaddr_can
340
+	SizeofSockaddrALG       = C.sizeof_struct_sockaddr_alg
341
+	SizeofSockaddrVM        = C.sizeof_struct_sockaddr_vm
342
+	SizeofLinger            = C.sizeof_struct_linger
343
+	SizeofIovec             = C.sizeof_struct_iovec
344
+	SizeofIPMreq            = C.sizeof_struct_ip_mreq
345
+	SizeofIPMreqn           = C.sizeof_struct_ip_mreqn
346
+	SizeofIPv6Mreq          = C.sizeof_struct_ipv6_mreq
347
+	SizeofPacketMreq        = C.sizeof_struct_packet_mreq
348
+	SizeofMsghdr            = C.sizeof_struct_msghdr
349
+	SizeofCmsghdr           = C.sizeof_struct_cmsghdr
350
+	SizeofInet4Pktinfo      = C.sizeof_struct_in_pktinfo
351
+	SizeofInet6Pktinfo      = C.sizeof_struct_in6_pktinfo
352
+	SizeofIPv6MTUInfo       = C.sizeof_struct_ip6_mtuinfo
353
+	SizeofICMPv6Filter      = C.sizeof_struct_icmp6_filter
354
+	SizeofUcred             = C.sizeof_struct_ucred
355
+	SizeofTCPInfo           = C.sizeof_struct_tcp_info
356
+)
357
+
358
+// Netlink routing and interface messages
359
+
360
+const (
361
+	IFA_UNSPEC          = C.IFA_UNSPEC
362
+	IFA_ADDRESS         = C.IFA_ADDRESS
363
+	IFA_LOCAL           = C.IFA_LOCAL
364
+	IFA_LABEL           = C.IFA_LABEL
365
+	IFA_BROADCAST       = C.IFA_BROADCAST
366
+	IFA_ANYCAST         = C.IFA_ANYCAST
367
+	IFA_CACHEINFO       = C.IFA_CACHEINFO
368
+	IFA_MULTICAST       = C.IFA_MULTICAST
369
+	IFLA_UNSPEC         = C.IFLA_UNSPEC
370
+	IFLA_ADDRESS        = C.IFLA_ADDRESS
371
+	IFLA_BROADCAST      = C.IFLA_BROADCAST
372
+	IFLA_IFNAME         = C.IFLA_IFNAME
373
+	IFLA_MTU            = C.IFLA_MTU
374
+	IFLA_LINK           = C.IFLA_LINK
375
+	IFLA_QDISC          = C.IFLA_QDISC
376
+	IFLA_STATS          = C.IFLA_STATS
377
+	IFLA_COST           = C.IFLA_COST
378
+	IFLA_PRIORITY       = C.IFLA_PRIORITY
379
+	IFLA_MASTER         = C.IFLA_MASTER
380
+	IFLA_WIRELESS       = C.IFLA_WIRELESS
381
+	IFLA_PROTINFO       = C.IFLA_PROTINFO
382
+	IFLA_TXQLEN         = C.IFLA_TXQLEN
383
+	IFLA_MAP            = C.IFLA_MAP
384
+	IFLA_WEIGHT         = C.IFLA_WEIGHT
385
+	IFLA_OPERSTATE      = C.IFLA_OPERSTATE
386
+	IFLA_LINKMODE       = C.IFLA_LINKMODE
387
+	IFLA_LINKINFO       = C.IFLA_LINKINFO
388
+	IFLA_NET_NS_PID     = C.IFLA_NET_NS_PID
389
+	IFLA_IFALIAS        = C.IFLA_IFALIAS
390
+	IFLA_MAX            = C.IFLA_MAX
391
+	RT_SCOPE_UNIVERSE   = C.RT_SCOPE_UNIVERSE
392
+	RT_SCOPE_SITE       = C.RT_SCOPE_SITE
393
+	RT_SCOPE_LINK       = C.RT_SCOPE_LINK
394
+	RT_SCOPE_HOST       = C.RT_SCOPE_HOST
395
+	RT_SCOPE_NOWHERE    = C.RT_SCOPE_NOWHERE
396
+	RT_TABLE_UNSPEC     = C.RT_TABLE_UNSPEC
397
+	RT_TABLE_COMPAT     = C.RT_TABLE_COMPAT
398
+	RT_TABLE_DEFAULT    = C.RT_TABLE_DEFAULT
399
+	RT_TABLE_MAIN       = C.RT_TABLE_MAIN
400
+	RT_TABLE_LOCAL      = C.RT_TABLE_LOCAL
401
+	RT_TABLE_MAX        = C.RT_TABLE_MAX
402
+	RTA_UNSPEC          = C.RTA_UNSPEC
403
+	RTA_DST             = C.RTA_DST
404
+	RTA_SRC             = C.RTA_SRC
405
+	RTA_IIF             = C.RTA_IIF
406
+	RTA_OIF             = C.RTA_OIF
407
+	RTA_GATEWAY         = C.RTA_GATEWAY
408
+	RTA_PRIORITY        = C.RTA_PRIORITY
409
+	RTA_PREFSRC         = C.RTA_PREFSRC
410
+	RTA_METRICS         = C.RTA_METRICS
411
+	RTA_MULTIPATH       = C.RTA_MULTIPATH
412
+	RTA_FLOW            = C.RTA_FLOW
413
+	RTA_CACHEINFO       = C.RTA_CACHEINFO
414
+	RTA_TABLE           = C.RTA_TABLE
415
+	RTN_UNSPEC          = C.RTN_UNSPEC
416
+	RTN_UNICAST         = C.RTN_UNICAST
417
+	RTN_LOCAL           = C.RTN_LOCAL
418
+	RTN_BROADCAST       = C.RTN_BROADCAST
419
+	RTN_ANYCAST         = C.RTN_ANYCAST
420
+	RTN_MULTICAST       = C.RTN_MULTICAST
421
+	RTN_BLACKHOLE       = C.RTN_BLACKHOLE
422
+	RTN_UNREACHABLE     = C.RTN_UNREACHABLE
423
+	RTN_PROHIBIT        = C.RTN_PROHIBIT
424
+	RTN_THROW           = C.RTN_THROW
425
+	RTN_NAT             = C.RTN_NAT
426
+	RTN_XRESOLVE        = C.RTN_XRESOLVE
427
+	RTNLGRP_NONE        = C.RTNLGRP_NONE
428
+	RTNLGRP_LINK        = C.RTNLGRP_LINK
429
+	RTNLGRP_NOTIFY      = C.RTNLGRP_NOTIFY
430
+	RTNLGRP_NEIGH       = C.RTNLGRP_NEIGH
431
+	RTNLGRP_TC          = C.RTNLGRP_TC
432
+	RTNLGRP_IPV4_IFADDR = C.RTNLGRP_IPV4_IFADDR
433
+	RTNLGRP_IPV4_MROUTE = C.RTNLGRP_IPV4_MROUTE
434
+	RTNLGRP_IPV4_ROUTE  = C.RTNLGRP_IPV4_ROUTE
435
+	RTNLGRP_IPV4_RULE   = C.RTNLGRP_IPV4_RULE
436
+	RTNLGRP_IPV6_IFADDR = C.RTNLGRP_IPV6_IFADDR
437
+	RTNLGRP_IPV6_MROUTE = C.RTNLGRP_IPV6_MROUTE
438
+	RTNLGRP_IPV6_ROUTE  = C.RTNLGRP_IPV6_ROUTE
439
+	RTNLGRP_IPV6_IFINFO = C.RTNLGRP_IPV6_IFINFO
440
+	RTNLGRP_IPV6_PREFIX = C.RTNLGRP_IPV6_PREFIX
441
+	RTNLGRP_IPV6_RULE   = C.RTNLGRP_IPV6_RULE
442
+	RTNLGRP_ND_USEROPT  = C.RTNLGRP_ND_USEROPT
443
+	SizeofNlMsghdr      = C.sizeof_struct_nlmsghdr
444
+	SizeofNlMsgerr      = C.sizeof_struct_nlmsgerr
445
+	SizeofRtGenmsg      = C.sizeof_struct_rtgenmsg
446
+	SizeofNlAttr        = C.sizeof_struct_nlattr
447
+	SizeofRtAttr        = C.sizeof_struct_rtattr
448
+	SizeofIfInfomsg     = C.sizeof_struct_ifinfomsg
449
+	SizeofIfAddrmsg     = C.sizeof_struct_ifaddrmsg
450
+	SizeofRtMsg         = C.sizeof_struct_rtmsg
451
+	SizeofRtNexthop     = C.sizeof_struct_rtnexthop
452
+)
453
+
454
+type NlMsghdr C.struct_nlmsghdr
455
+
456
+type NlMsgerr C.struct_nlmsgerr
457
+
458
+type RtGenmsg C.struct_rtgenmsg
459
+
460
+type NlAttr C.struct_nlattr
461
+
462
+type RtAttr C.struct_rtattr
463
+
464
+type IfInfomsg C.struct_ifinfomsg
465
+
466
+type IfAddrmsg C.struct_ifaddrmsg
467
+
468
+type RtMsg C.struct_rtmsg
469
+
470
+type RtNexthop C.struct_rtnexthop
471
+
472
+// Linux socket filter
473
+
474
+const (
475
+	SizeofSockFilter = C.sizeof_struct_sock_filter
476
+	SizeofSockFprog  = C.sizeof_struct_sock_fprog
477
+)
478
+
479
+type SockFilter C.struct_sock_filter
480
+
481
+type SockFprog C.struct_sock_fprog
482
+
483
+// Inotify
484
+
485
+type InotifyEvent C.struct_inotify_event
486
+
487
+const SizeofInotifyEvent = C.sizeof_struct_inotify_event
488
+
489
+// Ptrace
490
+
491
+// Register structures
492
+type PtraceRegs C.PtraceRegs
493
+
494
+// Structures contained in PtraceRegs on s390x (exported by mkpost.go)
495
+type PtracePsw C.ptracePsw
496
+
497
+type PtraceFpregs C.ptraceFpregs
498
+
499
+type PtracePer C.ptracePer
500
+
501
+// Misc
502
+
503
+type FdSet C.fd_set
504
+
505
+type Sysinfo_t C.struct_sysinfo
506
+
507
+type Utsname C.struct_utsname
508
+
509
+type Ustat_t C.struct_ustat
510
+
511
+type EpollEvent C.struct_my_epoll_event
512
+
513
+const (
514
+	AT_FDCWD            = C.AT_FDCWD
515
+	AT_REMOVEDIR        = C.AT_REMOVEDIR
516
+	AT_SYMLINK_FOLLOW   = C.AT_SYMLINK_FOLLOW
517
+	AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
518
+)
519
+
520
+type PollFd C.struct_pollfd
521
+
522
+const (
523
+	POLLIN    = C.POLLIN
524
+	POLLPRI   = C.POLLPRI
525
+	POLLOUT   = C.POLLOUT
526
+	POLLRDHUP = C.POLLRDHUP
527
+	POLLERR   = C.POLLERR
528
+	POLLHUP   = C.POLLHUP
529
+	POLLNVAL  = C.POLLNVAL
530
+)
531
+
532
+type Sigset_t C.sigset_t
533
+
534
+const RNDGETENTCNT = C.RNDGETENTCNT
535
+
536
+const PERF_IOC_FLAG_GROUP = C.PERF_IOC_FLAG_GROUP
537
+
538
+// Terminal handling
539
+
540
+type Termios C.termios_t
541
+
542
+type Winsize C.struct_winsize
543
+
544
+// Taskstats
545
+
546
+type Taskstats C.struct_taskstats
547
+
548
+const (
549
+	TASKSTATS_CMD_UNSPEC                  = C.TASKSTATS_CMD_UNSPEC
550
+	TASKSTATS_CMD_GET                     = C.TASKSTATS_CMD_GET
551
+	TASKSTATS_CMD_NEW                     = C.TASKSTATS_CMD_NEW
552
+	TASKSTATS_TYPE_UNSPEC                 = C.TASKSTATS_TYPE_UNSPEC
553
+	TASKSTATS_TYPE_PID                    = C.TASKSTATS_TYPE_PID
554
+	TASKSTATS_TYPE_TGID                   = C.TASKSTATS_TYPE_TGID
555
+	TASKSTATS_TYPE_STATS                  = C.TASKSTATS_TYPE_STATS
556
+	TASKSTATS_TYPE_AGGR_PID               = C.TASKSTATS_TYPE_AGGR_PID
557
+	TASKSTATS_TYPE_AGGR_TGID              = C.TASKSTATS_TYPE_AGGR_TGID
558
+	TASKSTATS_TYPE_NULL                   = C.TASKSTATS_TYPE_NULL
559
+	TASKSTATS_CMD_ATTR_UNSPEC             = C.TASKSTATS_CMD_ATTR_UNSPEC
560
+	TASKSTATS_CMD_ATTR_PID                = C.TASKSTATS_CMD_ATTR_PID
561
+	TASKSTATS_CMD_ATTR_TGID               = C.TASKSTATS_CMD_ATTR_TGID
562
+	TASKSTATS_CMD_ATTR_REGISTER_CPUMASK   = C.TASKSTATS_CMD_ATTR_REGISTER_CPUMASK
563
+	TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK = C.TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK
564
+)
565
+
566
+// Generic netlink
567
+
568
+type Genlmsghdr C.struct_genlmsghdr
569
+
570
+const (
571
+	CTRL_CMD_UNSPEC            = C.CTRL_CMD_UNSPEC
572
+	CTRL_CMD_NEWFAMILY         = C.CTRL_CMD_NEWFAMILY
573
+	CTRL_CMD_DELFAMILY         = C.CTRL_CMD_DELFAMILY
574
+	CTRL_CMD_GETFAMILY         = C.CTRL_CMD_GETFAMILY
575
+	CTRL_CMD_NEWOPS            = C.CTRL_CMD_NEWOPS
576
+	CTRL_CMD_DELOPS            = C.CTRL_CMD_DELOPS
577
+	CTRL_CMD_GETOPS            = C.CTRL_CMD_GETOPS
578
+	CTRL_CMD_NEWMCAST_GRP      = C.CTRL_CMD_NEWMCAST_GRP
579
+	CTRL_CMD_DELMCAST_GRP      = C.CTRL_CMD_DELMCAST_GRP
580
+	CTRL_CMD_GETMCAST_GRP      = C.CTRL_CMD_GETMCAST_GRP
581
+	CTRL_ATTR_UNSPEC           = C.CTRL_ATTR_UNSPEC
582
+	CTRL_ATTR_FAMILY_ID        = C.CTRL_ATTR_FAMILY_ID
583
+	CTRL_ATTR_FAMILY_NAME      = C.CTRL_ATTR_FAMILY_NAME
584
+	CTRL_ATTR_VERSION          = C.CTRL_ATTR_VERSION
585
+	CTRL_ATTR_HDRSIZE          = C.CTRL_ATTR_HDRSIZE
586
+	CTRL_ATTR_MAXATTR          = C.CTRL_ATTR_MAXATTR
587
+	CTRL_ATTR_OPS              = C.CTRL_ATTR_OPS
588
+	CTRL_ATTR_MCAST_GROUPS     = C.CTRL_ATTR_MCAST_GROUPS
589
+	CTRL_ATTR_OP_UNSPEC        = C.CTRL_ATTR_OP_UNSPEC
590
+	CTRL_ATTR_OP_ID            = C.CTRL_ATTR_OP_ID
591
+	CTRL_ATTR_OP_FLAGS         = C.CTRL_ATTR_OP_FLAGS
592
+	CTRL_ATTR_MCAST_GRP_UNSPEC = C.CTRL_ATTR_MCAST_GRP_UNSPEC
593
+	CTRL_ATTR_MCAST_GRP_NAME   = C.CTRL_ATTR_MCAST_GRP_NAME
594
+	CTRL_ATTR_MCAST_GRP_ID     = C.CTRL_ATTR_MCAST_GRP_ID
595
+)

+ 194
- 0
vendor/src/golang.org/x/sys/unix/mkall.sh Ver fichero

@@ -0,0 +1,194 @@
1
+#!/usr/bin/env bash
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+
6
+# This script runs or (given -n) prints suggested commands to generate files for
7
+# the Architecture/OS specified by the GOARCH and GOOS environment variables.
8
+# See README.md for more information about how the build system works.
9
+
10
+GOOSARCH="${GOOS}_${GOARCH}"
11
+
12
+# defaults
13
+mksyscall="./mksyscall.pl"
14
+mkerrors="./mkerrors.sh"
15
+zerrors="zerrors_$GOOSARCH.go"
16
+mksysctl=""
17
+zsysctl="zsysctl_$GOOSARCH.go"
18
+mksysnum=
19
+mktypes=
20
+run="sh"
21
+cmd=""
22
+
23
+case "$1" in
24
+-syscalls)
25
+	for i in zsyscall*go
26
+	do
27
+		# Run the command line that appears in the first line
28
+		# of the generated file to regenerate it.
29
+		sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
30
+		rm _$i
31
+	done
32
+	exit 0
33
+	;;
34
+-n)
35
+	run="cat"
36
+	cmd="echo"
37
+	shift
38
+esac
39
+
40
+case "$#" in
41
+0)
42
+	;;
43
+*)
44
+	echo 'usage: mkall.sh [-n]' 1>&2
45
+	exit 2
46
+esac
47
+
48
+if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
49
+	# Use then new build system
50
+	# Files generated through docker (use $cmd so you can Ctl-C the build or run)
51
+	$cmd docker build --tag generate:$GOOS $GOOS
52
+	$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
53
+	exit
54
+fi
55
+
56
+GOOSARCH_in=syscall_$GOOSARCH.go
57
+case "$GOOSARCH" in
58
+_* | *_ | _)
59
+	echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
60
+	exit 1
61
+	;;
62
+darwin_386)
63
+	mkerrors="$mkerrors -m32"
64
+	mksyscall="./mksyscall.pl -l32"
65
+	mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
66
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
67
+	;;
68
+darwin_amd64)
69
+	mkerrors="$mkerrors -m64"
70
+	mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
71
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
72
+	;;
73
+darwin_arm)
74
+	mkerrors="$mkerrors"
75
+	mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
76
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
77
+	;;
78
+darwin_arm64)
79
+	mkerrors="$mkerrors -m64"
80
+	mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
81
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
82
+	;;
83
+dragonfly_386)
84
+	mkerrors="$mkerrors -m32"
85
+	mksyscall="./mksyscall.pl -l32 -dragonfly"
86
+	mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
87
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
88
+	;;
89
+dragonfly_amd64)
90
+	mkerrors="$mkerrors -m64"
91
+	mksyscall="./mksyscall.pl -dragonfly"
92
+	mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
93
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
94
+	;;
95
+freebsd_386)
96
+	mkerrors="$mkerrors -m32"
97
+	mksyscall="./mksyscall.pl -l32"
98
+	mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
99
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
100
+	;;
101
+freebsd_amd64)
102
+	mkerrors="$mkerrors -m64"
103
+	mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
104
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
105
+	;;
106
+freebsd_arm)
107
+	mkerrors="$mkerrors"
108
+	mksyscall="./mksyscall.pl -l32 -arm"
109
+	mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
110
+	# Let the type of C char be signed for making the bare syscall
111
+	# API consistent across platforms.
112
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
113
+	;;
114
+linux_sparc64)
115
+	GOOSARCH_in=syscall_linux_sparc64.go
116
+	unistd_h=/usr/include/sparc64-linux-gnu/asm/unistd.h
117
+	mkerrors="$mkerrors -m64"
118
+	mksysnum="./mksysnum_linux.pl $unistd_h"
119
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
120
+	;;
121
+netbsd_386)
122
+	mkerrors="$mkerrors -m32"
123
+	mksyscall="./mksyscall.pl -l32 -netbsd"
124
+	mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
125
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
126
+	;;
127
+netbsd_amd64)
128
+	mkerrors="$mkerrors -m64"
129
+	mksyscall="./mksyscall.pl -netbsd"
130
+	mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
131
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
132
+	;;
133
+netbsd_arm)
134
+	mkerrors="$mkerrors"
135
+	mksyscall="./mksyscall.pl -l32 -netbsd -arm"
136
+	mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
137
+	# Let the type of C char be signed for making the bare syscall
138
+	# API consistent across platforms.
139
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
140
+	;;
141
+openbsd_386)
142
+	mkerrors="$mkerrors -m32"
143
+	mksyscall="./mksyscall.pl -l32 -openbsd"
144
+	mksysctl="./mksysctl_openbsd.pl"
145
+	mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
146
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
147
+	;;
148
+openbsd_amd64)
149
+	mkerrors="$mkerrors -m64"
150
+	mksyscall="./mksyscall.pl -openbsd"
151
+	mksysctl="./mksysctl_openbsd.pl"
152
+	mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
153
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
154
+	;;
155
+openbsd_arm)
156
+	mkerrors="$mkerrors"
157
+	mksyscall="./mksyscall.pl -l32 -openbsd -arm"
158
+	mksysctl="./mksysctl_openbsd.pl"
159
+	mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
160
+	# Let the type of C char be signed for making the bare syscall
161
+	# API consistent across platforms.
162
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
163
+	;;
164
+solaris_amd64)
165
+	mksyscall="./mksyscall_solaris.pl"
166
+	mkerrors="$mkerrors -m64"
167
+	mksysnum=
168
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
169
+	;;
170
+*)
171
+	echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
172
+	exit 1
173
+	;;
174
+esac
175
+
176
+(
177
+	if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
178
+	case "$GOOS" in
179
+	*)
180
+		syscall_goos="syscall_$GOOS.go"
181
+		case "$GOOS" in
182
+		darwin | dragonfly | freebsd | netbsd | openbsd)
183
+			syscall_goos="syscall_bsd.go $syscall_goos"
184
+			;;
185
+		esac
186
+		if [ -n "$mksyscall" ]; then echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; fi
187
+		;;
188
+	esac
189
+	if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
190
+	if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
191
+	if [ -n "$mktypes" ]; then
192
+		echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go";
193
+	fi
194
+) | $run

+ 577
- 0
vendor/src/golang.org/x/sys/unix/mkerrors.sh Ver fichero

@@ -0,0 +1,577 @@
1
+#!/usr/bin/env bash
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+
6
+# Generate Go code listing errors and other #defined constant
7
+# values (ENAMETOOLONG etc.), by asking the preprocessor
8
+# about the definitions.
9
+
10
+unset LANG
11
+export LC_ALL=C
12
+export LC_CTYPE=C
13
+
14
+if test -z "$GOARCH" -o -z "$GOOS"; then
15
+	echo 1>&2 "GOARCH or GOOS not defined in environment"
16
+	exit 1
17
+fi
18
+
19
+# Check that we are using the new build system if we should
20
+if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
21
+	if [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
22
+		echo 1>&2 "In the new build system, mkerrors should not be called directly."
23
+		echo 1>&2 "See README.md"
24
+		exit 1
25
+	fi
26
+fi
27
+
28
+CC=${CC:-cc}
29
+
30
+if [[ "$GOOS" = "solaris" ]]; then
31
+	# Assumes GNU versions of utilities in PATH.
32
+	export PATH=/usr/gnu/bin:$PATH
33
+fi
34
+
35
+uname=$(uname)
36
+
37
+includes_Darwin='
38
+#define _DARWIN_C_SOURCE
39
+#define KERNEL
40
+#define _DARWIN_USE_64_BIT_INODE
41
+#include <stdint.h>
42
+#include <sys/attr.h>
43
+#include <sys/types.h>
44
+#include <sys/event.h>
45
+#include <sys/ptrace.h>
46
+#include <sys/socket.h>
47
+#include <sys/sockio.h>
48
+#include <sys/sysctl.h>
49
+#include <sys/mman.h>
50
+#include <sys/mount.h>
51
+#include <sys/utsname.h>
52
+#include <sys/wait.h>
53
+#include <net/bpf.h>
54
+#include <net/if.h>
55
+#include <net/if_types.h>
56
+#include <net/route.h>
57
+#include <netinet/in.h>
58
+#include <netinet/ip.h>
59
+#include <termios.h>
60
+'
61
+
62
+includes_DragonFly='
63
+#include <sys/types.h>
64
+#include <sys/event.h>
65
+#include <sys/socket.h>
66
+#include <sys/sockio.h>
67
+#include <sys/sysctl.h>
68
+#include <sys/mman.h>
69
+#include <sys/wait.h>
70
+#include <sys/ioctl.h>
71
+#include <net/bpf.h>
72
+#include <net/if.h>
73
+#include <net/if_types.h>
74
+#include <net/route.h>
75
+#include <netinet/in.h>
76
+#include <termios.h>
77
+#include <netinet/ip.h>
78
+#include <net/ip_mroute/ip_mroute.h>
79
+'
80
+
81
+includes_FreeBSD='
82
+#include <sys/capability.h>
83
+#include <sys/param.h>
84
+#include <sys/types.h>
85
+#include <sys/event.h>
86
+#include <sys/socket.h>
87
+#include <sys/sockio.h>
88
+#include <sys/sysctl.h>
89
+#include <sys/mman.h>
90
+#include <sys/mount.h>
91
+#include <sys/wait.h>
92
+#include <sys/ioctl.h>
93
+#include <net/bpf.h>
94
+#include <net/if.h>
95
+#include <net/if_types.h>
96
+#include <net/route.h>
97
+#include <netinet/in.h>
98
+#include <termios.h>
99
+#include <netinet/ip.h>
100
+#include <netinet/ip_mroute.h>
101
+#include <sys/extattr.h>
102
+
103
+#if __FreeBSD__ >= 10
104
+#define IFT_CARP	0xf8	// IFT_CARP is deprecated in FreeBSD 10
105
+#undef SIOCAIFADDR
106
+#define SIOCAIFADDR	_IOW(105, 26, struct oifaliasreq)	// ifaliasreq contains if_data
107
+#undef SIOCSIFPHYADDR
108
+#define SIOCSIFPHYADDR	_IOW(105, 70, struct oifaliasreq)	// ifaliasreq contains if_data
109
+#endif
110
+'
111
+
112
+includes_Linux='
113
+#define _LARGEFILE_SOURCE
114
+#define _LARGEFILE64_SOURCE
115
+#ifndef __LP64__
116
+#define _FILE_OFFSET_BITS 64
117
+#endif
118
+#define _GNU_SOURCE
119
+
120
+// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
121
+// these structures. We just include them copied from <bits/termios.h>.
122
+#if defined(__powerpc__)
123
+struct sgttyb {
124
+        char    sg_ispeed;
125
+        char    sg_ospeed;
126
+        char    sg_erase;
127
+        char    sg_kill;
128
+        short   sg_flags;
129
+};
130
+
131
+struct tchars {
132
+        char    t_intrc;
133
+        char    t_quitc;
134
+        char    t_startc;
135
+        char    t_stopc;
136
+        char    t_eofc;
137
+        char    t_brkc;
138
+};
139
+
140
+struct ltchars {
141
+        char    t_suspc;
142
+        char    t_dsuspc;
143
+        char    t_rprntc;
144
+        char    t_flushc;
145
+        char    t_werasc;
146
+        char    t_lnextc;
147
+};
148
+#endif
149
+
150
+#include <bits/sockaddr.h>
151
+#include <sys/epoll.h>
152
+#include <sys/eventfd.h>
153
+#include <sys/inotify.h>
154
+#include <sys/ioctl.h>
155
+#include <sys/mman.h>
156
+#include <sys/mount.h>
157
+#include <sys/prctl.h>
158
+#include <sys/stat.h>
159
+#include <sys/types.h>
160
+#include <sys/time.h>
161
+#include <sys/socket.h>
162
+#include <sys/xattr.h>
163
+#include <linux/if.h>
164
+#include <linux/if_alg.h>
165
+#include <linux/if_arp.h>
166
+#include <linux/if_ether.h>
167
+#include <linux/if_tun.h>
168
+#include <linux/if_packet.h>
169
+#include <linux/if_addr.h>
170
+#include <linux/falloc.h>
171
+#include <linux/filter.h>
172
+#include <linux/fs.h>
173
+#include <linux/keyctl.h>
174
+#include <linux/netlink.h>
175
+#include <linux/perf_event.h>
176
+#include <linux/random.h>
177
+#include <linux/reboot.h>
178
+#include <linux/rtnetlink.h>
179
+#include <linux/ptrace.h>
180
+#include <linux/sched.h>
181
+#include <linux/seccomp.h>
182
+#include <linux/sockios.h>
183
+#include <linux/wait.h>
184
+#include <linux/icmpv6.h>
185
+#include <linux/serial.h>
186
+#include <linux/can.h>
187
+#include <linux/vm_sockets.h>
188
+#include <linux/taskstats.h>
189
+#include <linux/genetlink.h>
190
+#include <linux/watchdog.h>
191
+#include <net/route.h>
192
+#include <asm/termbits.h>
193
+
194
+#ifndef MSG_FASTOPEN
195
+#define MSG_FASTOPEN    0x20000000
196
+#endif
197
+
198
+#ifndef PTRACE_GETREGS
199
+#define PTRACE_GETREGS	0xc
200
+#endif
201
+
202
+#ifndef PTRACE_SETREGS
203
+#define PTRACE_SETREGS	0xd
204
+#endif
205
+
206
+#ifndef SOL_NETLINK
207
+#define SOL_NETLINK	270
208
+#endif
209
+
210
+#ifdef SOL_BLUETOOTH
211
+// SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h
212
+// but it is already in bluetooth_linux.go
213
+#undef SOL_BLUETOOTH
214
+#endif
215
+
216
+// Certain constants are missing from the fs/crypto UAPI
217
+#define FS_KEY_DESC_PREFIX              "fscrypt:"
218
+#define FS_KEY_DESC_PREFIX_SIZE         8
219
+#define FS_MAX_KEY_SIZE                 64
220
+'
221
+
222
+includes_NetBSD='
223
+#include <sys/types.h>
224
+#include <sys/param.h>
225
+#include <sys/event.h>
226
+#include <sys/mman.h>
227
+#include <sys/socket.h>
228
+#include <sys/sockio.h>
229
+#include <sys/sysctl.h>
230
+#include <sys/termios.h>
231
+#include <sys/ttycom.h>
232
+#include <sys/wait.h>
233
+#include <net/bpf.h>
234
+#include <net/if.h>
235
+#include <net/if_types.h>
236
+#include <net/route.h>
237
+#include <netinet/in.h>
238
+#include <netinet/in_systm.h>
239
+#include <netinet/ip.h>
240
+#include <netinet/ip_mroute.h>
241
+#include <netinet/if_ether.h>
242
+
243
+// Needed since <sys/param.h> refers to it...
244
+#define schedppq 1
245
+'
246
+
247
+includes_OpenBSD='
248
+#include <sys/types.h>
249
+#include <sys/param.h>
250
+#include <sys/event.h>
251
+#include <sys/mman.h>
252
+#include <sys/socket.h>
253
+#include <sys/sockio.h>
254
+#include <sys/sysctl.h>
255
+#include <sys/termios.h>
256
+#include <sys/ttycom.h>
257
+#include <sys/wait.h>
258
+#include <net/bpf.h>
259
+#include <net/if.h>
260
+#include <net/if_types.h>
261
+#include <net/if_var.h>
262
+#include <net/route.h>
263
+#include <netinet/in.h>
264
+#include <netinet/in_systm.h>
265
+#include <netinet/ip.h>
266
+#include <netinet/ip_mroute.h>
267
+#include <netinet/if_ether.h>
268
+#include <net/if_bridge.h>
269
+
270
+// We keep some constants not supported in OpenBSD 5.5 and beyond for
271
+// the promise of compatibility.
272
+#define EMUL_ENABLED		0x1
273
+#define EMUL_NATIVE		0x2
274
+#define IPV6_FAITH		0x1d
275
+#define IPV6_OPTIONS		0x1
276
+#define IPV6_RTHDR_STRICT	0x1
277
+#define IPV6_SOCKOPT_RESERVED1	0x3
278
+#define SIOCGIFGENERIC		0xc020693a
279
+#define SIOCSIFGENERIC		0x80206939
280
+#define WALTSIG			0x4
281
+'
282
+
283
+includes_SunOS='
284
+#include <limits.h>
285
+#include <sys/types.h>
286
+#include <sys/socket.h>
287
+#include <sys/sockio.h>
288
+#include <sys/mman.h>
289
+#include <sys/wait.h>
290
+#include <sys/ioctl.h>
291
+#include <sys/mkdev.h>
292
+#include <net/bpf.h>
293
+#include <net/if.h>
294
+#include <net/if_arp.h>
295
+#include <net/if_types.h>
296
+#include <net/route.h>
297
+#include <netinet/in.h>
298
+#include <termios.h>
299
+#include <netinet/ip.h>
300
+#include <netinet/ip_mroute.h>
301
+'
302
+
303
+
304
+includes='
305
+#include <sys/types.h>
306
+#include <sys/file.h>
307
+#include <fcntl.h>
308
+#include <dirent.h>
309
+#include <sys/socket.h>
310
+#include <netinet/in.h>
311
+#include <netinet/ip.h>
312
+#include <netinet/ip6.h>
313
+#include <netinet/tcp.h>
314
+#include <errno.h>
315
+#include <sys/signal.h>
316
+#include <signal.h>
317
+#include <sys/resource.h>
318
+#include <time.h>
319
+'
320
+ccflags="$@"
321
+
322
+# Write go tool cgo -godefs input.
323
+(
324
+	echo package unix
325
+	echo
326
+	echo '/*'
327
+	indirect="includes_$(uname)"
328
+	echo "${!indirect} $includes"
329
+	echo '*/'
330
+	echo 'import "C"'
331
+	echo 'import "syscall"'
332
+	echo
333
+	echo 'const ('
334
+
335
+	# The gcc command line prints all the #defines
336
+	# it encounters while processing the input
337
+	echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags |
338
+	awk '
339
+		$1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
340
+
341
+		$2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next}  # 386 registers
342
+		$2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next}
343
+		$2 ~ /^(SCM_SRCRT)$/ {next}
344
+		$2 ~ /^(MAP_FAILED)$/ {next}
345
+		$2 ~ /^ELF_.*$/ {next}# <asm/elf.h> contains ELF_ARCH, etc.
346
+
347
+		$2 ~ /^EXTATTR_NAMESPACE_NAMES/ ||
348
+		$2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next}
349
+
350
+		$2 !~ /^ETH_/ &&
351
+		$2 !~ /^EPROC_/ &&
352
+		$2 !~ /^EQUIV_/ &&
353
+		$2 !~ /^EXPR_/ &&
354
+		$2 ~ /^E[A-Z0-9_]+$/ ||
355
+		$2 ~ /^B[0-9_]+$/ ||
356
+		$2 ~ /^(OLD|NEW)DEV$/ ||
357
+		$2 == "BOTHER" ||
358
+		$2 ~ /^CI?BAUD(EX)?$/ ||
359
+		$2 == "IBSHIFT" ||
360
+		$2 ~ /^V[A-Z0-9]+$/ ||
361
+		$2 ~ /^CS[A-Z0-9]/ ||
362
+		$2 ~ /^I(SIG|CANON|CRNL|UCLC|EXTEN|MAXBEL|STRIP|UTF8)$/ ||
363
+		$2 ~ /^IGN/ ||
364
+		$2 ~ /^IX(ON|ANY|OFF)$/ ||
365
+		$2 ~ /^IN(LCR|PCK)$/ ||
366
+		$2 ~ /(^FLU?SH)|(FLU?SH$)/ ||
367
+		$2 ~ /^C(LOCAL|READ|MSPAR|RTSCTS)$/ ||
368
+		$2 == "BRKINT" ||
369
+		$2 == "HUPCL" ||
370
+		$2 == "PENDIN" ||
371
+		$2 == "TOSTOP" ||
372
+		$2 == "XCASE" ||
373
+		$2 == "ALTWERASE" ||
374
+		$2 == "NOKERNINFO" ||
375
+		$2 ~ /^PAR/ ||
376
+		$2 ~ /^SIG[^_]/ ||
377
+		$2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
378
+		$2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ ||
379
+		$2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ ||
380
+		$2 ~ /^O?XTABS$/ ||
381
+		$2 ~ /^TC[IO](ON|OFF)$/ ||
382
+		$2 ~ /^IN_/ ||
383
+		$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
384
+		$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
385
+		$2 ~ /^FALLOC_/ ||
386
+		$2 == "ICMPV6_FILTER" ||
387
+		$2 == "SOMAXCONN" ||
388
+		$2 == "NAME_MAX" ||
389
+		$2 == "IFNAMSIZ" ||
390
+		$2 ~ /^CTL_(HW|KERN|MAXNAME|NET|QUERY)$/ ||
391
+		$2 ~ /^KERN_(HOSTNAME|OS(RELEASE|TYPE)|VERSION)$/ ||
392
+		$2 ~ /^HW_MACHINE$/ ||
393
+		$2 ~ /^SYSCTL_VERS/ ||
394
+		$2 ~ /^(MS|MNT|UMOUNT)_/ ||
395
+		$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
396
+		$2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ ||
397
+		$2 ~ /^LINUX_REBOOT_CMD_/ ||
398
+		$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
399
+		$2 !~ "NLA_TYPE_MASK" &&
400
+		$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
401
+		$2 ~ /^SIOC/ ||
402
+		$2 ~ /^TIOC/ ||
403
+		$2 ~ /^TCGET/ ||
404
+		$2 ~ /^TCSET/ ||
405
+		$2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
406
+		$2 !~ "RTF_BITS" &&
407
+		$2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
408
+		$2 ~ /^BIOC/ ||
409
+		$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
410
+		$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
411
+		$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
412
+		$2 ~ /^CLONE_[A-Z_]+/ ||
413
+		$2 !~ /^(BPF_TIMEVAL)$/ &&
414
+		$2 ~ /^(BPF|DLT)_/ ||
415
+		$2 ~ /^CLOCK_/ ||
416
+		$2 ~ /^CAN_/ ||
417
+		$2 ~ /^CAP_/ ||
418
+		$2 ~ /^ALG_/ ||
419
+		$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE|IOC_(GET|SET)_ENCRYPTION)/ ||
420
+		$2 ~ /^GRND_/ ||
421
+		$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
422
+		$2 ~ /^KEYCTL_/ ||
423
+		$2 ~ /^PERF_EVENT_IOC_/ ||
424
+		$2 ~ /^SECCOMP_MODE_/ ||
425
+		$2 ~ /^SPLICE_/ ||
426
+		$2 ~ /^(VM|VMADDR)_/ ||
427
+		$2 ~ /^IOCTL_VM_SOCKETS_/ ||
428
+		$2 ~ /^(TASKSTATS|TS)_/ ||
429
+		$2 ~ /^GENL_/ ||
430
+		$2 ~ /^UTIME_/ ||
431
+		$2 ~ /^XATTR_(CREATE|REPLACE)/ ||
432
+		$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
433
+		$2 ~ /^FSOPT_/ ||
434
+		$2 ~ /^WDIOC_/ ||
435
+		$2 !~ "WMESGLEN" &&
436
+		$2 ~ /^W[A-Z0-9]+$/ ||
437
+		$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
438
+		$2 ~ /^__WCOREFLAG$/ {next}
439
+		$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
440
+
441
+		{next}
442
+	' | sort
443
+
444
+	echo ')'
445
+) >_const.go
446
+
447
+# Pull out the error names for later.
448
+errors=$(
449
+	echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
450
+	awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
451
+	sort
452
+)
453
+
454
+# Pull out the signal names for later.
455
+signals=$(
456
+	echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
457
+	awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
458
+	egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
459
+	sort
460
+)
461
+
462
+# Again, writing regexps to a file.
463
+echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
464
+	awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' |
465
+	sort >_error.grep
466
+echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
467
+	awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
468
+	egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
469
+	sort >_signal.grep
470
+
471
+echo '// mkerrors.sh' "$@"
472
+echo '// Code generated by the command above; see README.md. DO NOT EDIT.'
473
+echo
474
+echo "// +build ${GOARCH},${GOOS}"
475
+echo
476
+go tool cgo -godefs -- "$@" _const.go >_error.out
477
+cat _error.out | grep -vf _error.grep | grep -vf _signal.grep
478
+echo
479
+echo '// Errors'
480
+echo 'const ('
481
+cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= syscall.Errno(\1)/'
482
+echo ')'
483
+
484
+echo
485
+echo '// Signals'
486
+echo 'const ('
487
+cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= syscall.Signal(\1)/'
488
+echo ')'
489
+
490
+# Run C program to print error and syscall strings.
491
+(
492
+	echo -E "
493
+#include <stdio.h>
494
+#include <stdlib.h>
495
+#include <errno.h>
496
+#include <ctype.h>
497
+#include <string.h>
498
+#include <signal.h>
499
+
500
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
501
+
502
+enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below
503
+
504
+int errors[] = {
505
+"
506
+	for i in $errors
507
+	do
508
+		echo -E '	'$i,
509
+	done
510
+
511
+	echo -E "
512
+};
513
+
514
+int signals[] = {
515
+"
516
+	for i in $signals
517
+	do
518
+		echo -E '	'$i,
519
+	done
520
+
521
+	# Use -E because on some systems bash builtin interprets \n itself.
522
+	echo -E '
523
+};
524
+
525
+static int
526
+intcmp(const void *a, const void *b)
527
+{
528
+	return *(int*)a - *(int*)b;
529
+}
530
+
531
+int
532
+main(void)
533
+{
534
+	int i, e;
535
+	char buf[1024], *p;
536
+
537
+	printf("\n\n// Error table\n");
538
+	printf("var errors = [...]string {\n");
539
+	qsort(errors, nelem(errors), sizeof errors[0], intcmp);
540
+	for(i=0; i<nelem(errors); i++) {
541
+		e = errors[i];
542
+		if(i > 0 && errors[i-1] == e)
543
+			continue;
544
+		strcpy(buf, strerror(e));
545
+		// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
546
+		if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
547
+			buf[0] += a - A;
548
+		printf("\t%d: \"%s\",\n", e, buf);
549
+	}
550
+	printf("}\n\n");
551
+
552
+	printf("\n\n// Signal table\n");
553
+	printf("var signals = [...]string {\n");
554
+	qsort(signals, nelem(signals), sizeof signals[0], intcmp);
555
+	for(i=0; i<nelem(signals); i++) {
556
+		e = signals[i];
557
+		if(i > 0 && signals[i-1] == e)
558
+			continue;
559
+		strcpy(buf, strsignal(e));
560
+		// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
561
+		if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
562
+			buf[0] += a - A;
563
+		// cut trailing : number.
564
+		p = strrchr(buf, ":"[0]);
565
+		if(p)
566
+			*p = '\0';
567
+		printf("\t%d: \"%s\",\n", e, buf);
568
+	}
569
+	printf("}\n\n");
570
+
571
+	return 0;
572
+}
573
+
574
+'
575
+) >_errors.c
576
+
577
+$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out

+ 93
- 0
vendor/src/golang.org/x/sys/unix/mkpost.go Ver fichero

@@ -0,0 +1,93 @@
1
+// Copyright 2016 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
+// +build ignore
6
+
7
+// mkpost processes the output of cgo -godefs to
8
+// modify the generated types. It is used to clean up
9
+// the sys API in an architecture specific manner.
10
+//
11
+// mkpost is run after cgo -godefs; see README.md.
12
+package main
13
+
14
+import (
15
+	"bytes"
16
+	"fmt"
17
+	"go/format"
18
+	"io/ioutil"
19
+	"log"
20
+	"os"
21
+	"regexp"
22
+)
23
+
24
+func main() {
25
+	// Get the OS and architecture (using GOARCH_TARGET if it exists)
26
+	goos := os.Getenv("GOOS")
27
+	goarch := os.Getenv("GOARCH_TARGET")
28
+	if goarch == "" {
29
+		goarch = os.Getenv("GOARCH")
30
+	}
31
+	// Check that we are using the new build system if we should be.
32
+	if goos == "linux" && goarch != "sparc64" {
33
+		if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
34
+			os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n")
35
+			os.Stderr.WriteString("See README.md\n")
36
+			os.Exit(1)
37
+		}
38
+	}
39
+
40
+	b, err := ioutil.ReadAll(os.Stdin)
41
+	if err != nil {
42
+		log.Fatal(err)
43
+	}
44
+
45
+	// If we have empty Ptrace structs, we should delete them. Only s390x emits
46
+	// nonempty Ptrace structs.
47
+	ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)
48
+	b = ptraceRexexp.ReplaceAll(b, nil)
49
+
50
+	// Replace the control_regs union with a blank identifier for now.
51
+	controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`)
52
+	b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64"))
53
+
54
+	// Remove fields that are added by glibc
55
+	// Note that this is unstable as the identifers are private.
56
+	removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`)
57
+	b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
58
+
59
+	// Convert [65]int8 to [65]byte in Utsname members to simplify
60
+	// conversion to string; see golang.org/issue/20753
61
+	convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`)
62
+	b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte"))
63
+
64
+	// We refuse to export private fields on s390x
65
+	if goarch == "s390x" && goos == "linux" {
66
+		// Remove cgo padding fields
67
+		removeFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`)
68
+		b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
69
+
70
+		// Remove padding, hidden, or unused fields
71
+		removeFieldsRegex = regexp.MustCompile(`X_\S+`)
72
+		b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
73
+	}
74
+
75
+	// Remove the first line of warning from cgo
76
+	b = b[bytes.IndexByte(b, '\n')+1:]
77
+	// Modify the command in the header to include:
78
+	//  mkpost, our own warning, and a build tag.
79
+	replacement := fmt.Sprintf(`$1 | go run mkpost.go
80
+// Code generated by the command above; see README.md. DO NOT EDIT.
81
+
82
+// +build %s,%s`, goarch, goos)
83
+	cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`)
84
+	b = cgoCommandRegex.ReplaceAll(b, []byte(replacement))
85
+
86
+	// gofmt
87
+	b, err = format.Source(b)
88
+	if err != nil {
89
+		log.Fatal(err)
90
+	}
91
+
92
+	os.Stdout.Write(b)
93
+}

+ 328
- 0
vendor/src/golang.org/x/sys/unix/mksyscall.pl Ver fichero

@@ -0,0 +1,328 @@
1
+#!/usr/bin/env perl
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+
6
+# This program reads a file containing function prototypes
7
+# (like syscall_darwin.go) and generates system call bodies.
8
+# The prototypes are marked by lines beginning with "//sys"
9
+# and read like func declarations if //sys is replaced by func, but:
10
+#	* The parameter lists must give a name for each argument.
11
+#	  This includes return parameters.
12
+#	* The parameter lists must give a type for each argument:
13
+#	  the (x, y, z int) shorthand is not allowed.
14
+#	* If the return parameter is an error number, it must be named errno.
15
+
16
+# A line beginning with //sysnb is like //sys, except that the
17
+# goroutine will not be suspended during the execution of the system
18
+# call.  This must only be used for system calls which can never
19
+# block, as otherwise the system call could cause all goroutines to
20
+# hang.
21
+
22
+use strict;
23
+
24
+my $cmdline = "mksyscall.pl " . join(' ', @ARGV);
25
+my $errors = 0;
26
+my $_32bit = "";
27
+my $plan9 = 0;
28
+my $openbsd = 0;
29
+my $netbsd = 0;
30
+my $dragonfly = 0;
31
+my $arm = 0; # 64-bit value should use (even, odd)-pair
32
+my $tags = "";  # build tags
33
+
34
+if($ARGV[0] eq "-b32") {
35
+	$_32bit = "big-endian";
36
+	shift;
37
+} elsif($ARGV[0] eq "-l32") {
38
+	$_32bit = "little-endian";
39
+	shift;
40
+}
41
+if($ARGV[0] eq "-plan9") {
42
+	$plan9 = 1;
43
+	shift;
44
+}
45
+if($ARGV[0] eq "-openbsd") {
46
+	$openbsd = 1;
47
+	shift;
48
+}
49
+if($ARGV[0] eq "-netbsd") {
50
+	$netbsd = 1;
51
+	shift;
52
+}
53
+if($ARGV[0] eq "-dragonfly") {
54
+	$dragonfly = 1;
55
+	shift;
56
+}
57
+if($ARGV[0] eq "-arm") {
58
+	$arm = 1;
59
+	shift;
60
+}
61
+if($ARGV[0] eq "-tags") {
62
+	shift;
63
+	$tags = $ARGV[0];
64
+	shift;
65
+}
66
+
67
+if($ARGV[0] =~ /^-/) {
68
+	print STDERR "usage: mksyscall.pl [-b32 | -l32] [-tags x,y] [file ...]\n";
69
+	exit 1;
70
+}
71
+
72
+# Check that we are using the new build system if we should
73
+if($ENV{'GOOS'} eq "linux" && $ENV{'GOARCH'} ne "sparc64") {
74
+	if($ENV{'GOLANG_SYS_BUILD'} ne "docker") {
75
+		print STDERR "In the new build system, mksyscall should not be called directly.\n";
76
+		print STDERR "See README.md\n";
77
+		exit 1;
78
+	}
79
+}
80
+
81
+
82
+sub parseparamlist($) {
83
+	my ($list) = @_;
84
+	$list =~ s/^\s*//;
85
+	$list =~ s/\s*$//;
86
+	if($list eq "") {
87
+		return ();
88
+	}
89
+	return split(/\s*,\s*/, $list);
90
+}
91
+
92
+sub parseparam($) {
93
+	my ($p) = @_;
94
+	if($p !~ /^(\S*) (\S*)$/) {
95
+		print STDERR "$ARGV:$.: malformed parameter: $p\n";
96
+		$errors = 1;
97
+		return ("xx", "int");
98
+	}
99
+	return ($1, $2);
100
+}
101
+
102
+my $text = "";
103
+while(<>) {
104
+	chomp;
105
+	s/\s+/ /g;
106
+	s/^\s+//;
107
+	s/\s+$//;
108
+	my $nonblock = /^\/\/sysnb /;
109
+	next if !/^\/\/sys / && !$nonblock;
110
+
111
+	# Line must be of the form
112
+	#	func Open(path string, mode int, perm int) (fd int, errno error)
113
+	# Split into name, in params, out params.
114
+	if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) {
115
+		print STDERR "$ARGV:$.: malformed //sys declaration\n";
116
+		$errors = 1;
117
+		next;
118
+	}
119
+	my ($func, $in, $out, $sysname) = ($2, $3, $4, $5);
120
+
121
+	# Split argument lists on comma.
122
+	my @in = parseparamlist($in);
123
+	my @out = parseparamlist($out);
124
+
125
+	# Try in vain to keep people from editing this file.
126
+	# The theory is that they jump into the middle of the file
127
+	# without reading the header.
128
+	$text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
129
+
130
+	# Go function header.
131
+	my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
132
+	$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
133
+
134
+	# Check if err return available
135
+	my $errvar = "";
136
+	foreach my $p (@out) {
137
+		my ($name, $type) = parseparam($p);
138
+		if($type eq "error") {
139
+			$errvar = $name;
140
+			last;
141
+		}
142
+	}
143
+
144
+	# Prepare arguments to Syscall.
145
+	my @args = ();
146
+	my $n = 0;
147
+	foreach my $p (@in) {
148
+		my ($name, $type) = parseparam($p);
149
+		if($type =~ /^\*/) {
150
+			push @args, "uintptr(unsafe.Pointer($name))";
151
+		} elsif($type eq "string" && $errvar ne "") {
152
+			$text .= "\tvar _p$n *byte\n";
153
+			$text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
154
+			$text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
155
+			push @args, "uintptr(unsafe.Pointer(_p$n))";
156
+			$n++;
157
+		} elsif($type eq "string") {
158
+			print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
159
+			$text .= "\tvar _p$n *byte\n";
160
+			$text .= "\t_p$n, _ = BytePtrFromString($name)\n";
161
+			push @args, "uintptr(unsafe.Pointer(_p$n))";
162
+			$n++;
163
+		} elsif($type =~ /^\[\](.*)/) {
164
+			# Convert slice into pointer, length.
165
+			# Have to be careful not to take address of &a[0] if len == 0:
166
+			# pass dummy pointer in that case.
167
+			# Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
168
+			$text .= "\tvar _p$n unsafe.Pointer\n";
169
+			$text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}";
170
+			$text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}";
171
+			$text .= "\n";
172
+			push @args, "uintptr(_p$n)", "uintptr(len($name))";
173
+			$n++;
174
+		} elsif($type eq "int64" && ($openbsd || $netbsd)) {
175
+			push @args, "0";
176
+			if($_32bit eq "big-endian") {
177
+				push @args, "uintptr($name>>32)", "uintptr($name)";
178
+			} elsif($_32bit eq "little-endian") {
179
+				push @args, "uintptr($name)", "uintptr($name>>32)";
180
+			} else {
181
+				push @args, "uintptr($name)";
182
+			}
183
+		} elsif($type eq "int64" && $dragonfly) {
184
+			if ($func !~ /^extp(read|write)/i) {
185
+				push @args, "0";
186
+			}
187
+			if($_32bit eq "big-endian") {
188
+				push @args, "uintptr($name>>32)", "uintptr($name)";
189
+			} elsif($_32bit eq "little-endian") {
190
+				push @args, "uintptr($name)", "uintptr($name>>32)";
191
+			} else {
192
+				push @args, "uintptr($name)";
193
+			}
194
+		} elsif($type eq "int64" && $_32bit ne "") {
195
+			if(@args % 2 && $arm) {
196
+				# arm abi specifies 64-bit argument uses
197
+				# (even, odd) pair
198
+				push @args, "0"
199
+			}
200
+			if($_32bit eq "big-endian") {
201
+				push @args, "uintptr($name>>32)", "uintptr($name)";
202
+			} else {
203
+				push @args, "uintptr($name)", "uintptr($name>>32)";
204
+			}
205
+		} else {
206
+			push @args, "uintptr($name)";
207
+		}
208
+	}
209
+
210
+	# Determine which form to use; pad args with zeros.
211
+	my $asm = "Syscall";
212
+	if ($nonblock) {
213
+		$asm = "RawSyscall";
214
+	}
215
+	if(@args <= 3) {
216
+		while(@args < 3) {
217
+			push @args, "0";
218
+		}
219
+	} elsif(@args <= 6) {
220
+		$asm .= "6";
221
+		while(@args < 6) {
222
+			push @args, "0";
223
+		}
224
+	} elsif(@args <= 9) {
225
+		$asm .= "9";
226
+		while(@args < 9) {
227
+			push @args, "0";
228
+		}
229
+	} else {
230
+		print STDERR "$ARGV:$.: too many arguments to system call\n";
231
+	}
232
+
233
+	# System call number.
234
+	if($sysname eq "") {
235
+		$sysname = "SYS_$func";
236
+		$sysname =~ s/([a-z])([A-Z])/${1}_$2/g;	# turn FooBar into Foo_Bar
237
+		$sysname =~ y/a-z/A-Z/;
238
+	}
239
+
240
+	# Actual call.
241
+	my $args = join(', ', @args);
242
+	my $call = "$asm($sysname, $args)";
243
+
244
+	# Assign return values.
245
+	my $body = "";
246
+	my @ret = ("_", "_", "_");
247
+	my $do_errno = 0;
248
+	for(my $i=0; $i<@out; $i++) {
249
+		my $p = $out[$i];
250
+		my ($name, $type) = parseparam($p);
251
+		my $reg = "";
252
+		if($name eq "err" && !$plan9) {
253
+			$reg = "e1";
254
+			$ret[2] = $reg;
255
+			$do_errno = 1;
256
+		} elsif($name eq "err" && $plan9) {
257
+			$ret[0] = "r0";
258
+			$ret[2] = "e1";
259
+			next;
260
+		} else {
261
+			$reg = sprintf("r%d", $i);
262
+			$ret[$i] = $reg;
263
+		}
264
+		if($type eq "bool") {
265
+			$reg = "$reg != 0";
266
+		}
267
+		if($type eq "int64" && $_32bit ne "") {
268
+			# 64-bit number in r1:r0 or r0:r1.
269
+			if($i+2 > @out) {
270
+				print STDERR "$ARGV:$.: not enough registers for int64 return\n";
271
+			}
272
+			if($_32bit eq "big-endian") {
273
+				$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
274
+			} else {
275
+				$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
276
+			}
277
+			$ret[$i] = sprintf("r%d", $i);
278
+			$ret[$i+1] = sprintf("r%d", $i+1);
279
+		}
280
+		if($reg ne "e1" || $plan9) {
281
+			$body .= "\t$name = $type($reg)\n";
282
+		}
283
+	}
284
+	if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
285
+		$text .= "\t$call\n";
286
+	} else {
287
+		$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
288
+	}
289
+	$text .= $body;
290
+
291
+	if ($plan9 && $ret[2] eq "e1") {
292
+		$text .= "\tif int32(r0) == -1 {\n";
293
+		$text .= "\t\terr = e1\n";
294
+		$text .= "\t}\n";
295
+	} elsif ($do_errno) {
296
+		$text .= "\tif e1 != 0 {\n";
297
+		$text .= "\t\terr = errnoErr(e1)\n";
298
+		$text .= "\t}\n";
299
+	}
300
+	$text .= "\treturn\n";
301
+	$text .= "}\n\n";
302
+}
303
+
304
+chomp $text;
305
+chomp $text;
306
+
307
+if($errors) {
308
+	exit 1;
309
+}
310
+
311
+print <<EOF;
312
+// $cmdline
313
+// Code generated by the command above; see README.md. DO NOT EDIT.
314
+
315
+// +build $tags
316
+
317
+package unix
318
+
319
+import (
320
+	"syscall"
321
+	"unsafe"
322
+)
323
+
324
+var _ syscall.Errno
325
+
326
+$text
327
+EOF
328
+exit 0;

+ 289
- 0
vendor/src/golang.org/x/sys/unix/mksyscall_solaris.pl Ver fichero

@@ -0,0 +1,289 @@
1
+#!/usr/bin/env perl
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+
6
+# This program reads a file containing function prototypes
7
+# (like syscall_solaris.go) and generates system call bodies.
8
+# The prototypes are marked by lines beginning with "//sys"
9
+# and read like func declarations if //sys is replaced by func, but:
10
+#	* The parameter lists must give a name for each argument.
11
+#	  This includes return parameters.
12
+#	* The parameter lists must give a type for each argument:
13
+#	  the (x, y, z int) shorthand is not allowed.
14
+#	* If the return parameter is an error number, it must be named err.
15
+#	* If go func name needs to be different than its libc name,
16
+#	* or the function is not in libc, name could be specified
17
+#	* at the end, after "=" sign, like
18
+#	  //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
19
+
20
+use strict;
21
+
22
+my $cmdline = "mksyscall_solaris.pl " . join(' ', @ARGV);
23
+my $errors = 0;
24
+my $_32bit = "";
25
+my $tags = "";  # build tags
26
+
27
+binmode STDOUT;
28
+
29
+if($ARGV[0] eq "-b32") {
30
+	$_32bit = "big-endian";
31
+	shift;
32
+} elsif($ARGV[0] eq "-l32") {
33
+	$_32bit = "little-endian";
34
+	shift;
35
+}
36
+if($ARGV[0] eq "-tags") {
37
+	shift;
38
+	$tags = $ARGV[0];
39
+	shift;
40
+}
41
+
42
+if($ARGV[0] =~ /^-/) {
43
+	print STDERR "usage: mksyscall_solaris.pl [-b32 | -l32] [-tags x,y] [file ...]\n";
44
+	exit 1;
45
+}
46
+
47
+sub parseparamlist($) {
48
+	my ($list) = @_;
49
+	$list =~ s/^\s*//;
50
+	$list =~ s/\s*$//;
51
+	if($list eq "") {
52
+		return ();
53
+	}
54
+	return split(/\s*,\s*/, $list);
55
+}
56
+
57
+sub parseparam($) {
58
+	my ($p) = @_;
59
+	if($p !~ /^(\S*) (\S*)$/) {
60
+		print STDERR "$ARGV:$.: malformed parameter: $p\n";
61
+		$errors = 1;
62
+		return ("xx", "int");
63
+	}
64
+	return ($1, $2);
65
+}
66
+
67
+my $package = "";
68
+my $text = "";
69
+my $dynimports = "";
70
+my $linknames = "";
71
+my @vars = ();
72
+while(<>) {
73
+	chomp;
74
+	s/\s+/ /g;
75
+	s/^\s+//;
76
+	s/\s+$//;
77
+	$package = $1 if !$package && /^package (\S+)$/;
78
+	my $nonblock = /^\/\/sysnb /;
79
+	next if !/^\/\/sys / && !$nonblock;
80
+
81
+	# Line must be of the form
82
+	#	func Open(path string, mode int, perm int) (fd int, err error)
83
+	# Split into name, in params, out params.
84
+	if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) {
85
+		print STDERR "$ARGV:$.: malformed //sys declaration\n";
86
+		$errors = 1;
87
+		next;
88
+	}
89
+	my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, $6);
90
+
91
+	# Split argument lists on comma.
92
+	my @in = parseparamlist($in);
93
+	my @out = parseparamlist($out);
94
+
95
+	# So file name.
96
+	if($modname eq "") {
97
+		$modname = "libc";
98
+	}
99
+
100
+	# System call name.
101
+	if($sysname eq "") {
102
+		$sysname = "$func";
103
+	}
104
+
105
+	# System call pointer variable name.
106
+	my $sysvarname = "proc$sysname";
107
+
108
+	my $strconvfunc = "BytePtrFromString";
109
+	my $strconvtype = "*byte";
110
+
111
+	$sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
112
+
113
+	# Runtime import of function to allow cross-platform builds.
114
+	$dynimports .= "//go:cgo_import_dynamic libc_${sysname} ${sysname} \"$modname.so\"\n";
115
+	# Link symbol to proc address variable.
116
+	$linknames .= "//go:linkname ${sysvarname} libc_${sysname}\n";
117
+	# Library proc address variable.
118
+	push @vars, $sysvarname;
119
+
120
+	# Go function header.
121
+	$out = join(', ', @out);
122
+	if($out ne "") {
123
+		$out = " ($out)";
124
+	}
125
+	if($text ne "") {
126
+		$text .= "\n"
127
+	}
128
+	$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out;
129
+
130
+	# Check if err return available
131
+	my $errvar = "";
132
+	foreach my $p (@out) {
133
+		my ($name, $type) = parseparam($p);
134
+		if($type eq "error") {
135
+			$errvar = $name;
136
+			last;
137
+		}
138
+	}
139
+
140
+	# Prepare arguments to Syscall.
141
+	my @args = ();
142
+	my $n = 0;
143
+	foreach my $p (@in) {
144
+		my ($name, $type) = parseparam($p);
145
+		if($type =~ /^\*/) {
146
+			push @args, "uintptr(unsafe.Pointer($name))";
147
+		} elsif($type eq "string" && $errvar ne "") {
148
+			$text .= "\tvar _p$n $strconvtype\n";
149
+			$text .= "\t_p$n, $errvar = $strconvfunc($name)\n";
150
+			$text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
151
+			push @args, "uintptr(unsafe.Pointer(_p$n))";
152
+			$n++;
153
+		} elsif($type eq "string") {
154
+			print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
155
+			$text .= "\tvar _p$n $strconvtype\n";
156
+			$text .= "\t_p$n, _ = $strconvfunc($name)\n";
157
+			push @args, "uintptr(unsafe.Pointer(_p$n))";
158
+			$n++;
159
+		} elsif($type =~ /^\[\](.*)/) {
160
+			# Convert slice into pointer, length.
161
+			# Have to be careful not to take address of &a[0] if len == 0:
162
+			# pass nil in that case.
163
+			$text .= "\tvar _p$n *$1\n";
164
+			$text .= "\tif len($name) > 0 {\n\t\t_p$n = \&$name\[0]\n\t}\n";
165
+			push @args, "uintptr(unsafe.Pointer(_p$n))", "uintptr(len($name))";
166
+			$n++;
167
+		} elsif($type eq "int64" && $_32bit ne "") {
168
+			if($_32bit eq "big-endian") {
169
+				push @args, "uintptr($name >> 32)", "uintptr($name)";
170
+			} else {
171
+				push @args, "uintptr($name)", "uintptr($name >> 32)";
172
+			}
173
+		} elsif($type eq "bool") {
174
+ 			$text .= "\tvar _p$n uint32\n";
175
+			$text .= "\tif $name {\n\t\t_p$n = 1\n\t} else {\n\t\t_p$n = 0\n\t}\n";
176
+			push @args, "uintptr(_p$n)";
177
+			$n++;
178
+		} else {
179
+			push @args, "uintptr($name)";
180
+		}
181
+	}
182
+	my $nargs = @args;
183
+
184
+	# Determine which form to use; pad args with zeros.
185
+	my $asm = "sysvicall6";
186
+	if ($nonblock) {
187
+		$asm = "rawSysvicall6";
188
+	}
189
+	if(@args <= 6) {
190
+		while(@args < 6) {
191
+			push @args, "0";
192
+		}
193
+	} else {
194
+		print STDERR "$ARGV:$.: too many arguments to system call\n";
195
+	}
196
+
197
+	# Actual call.
198
+	my $args = join(', ', @args);
199
+	my $call = "$asm(uintptr(unsafe.Pointer(&$sysvarname)), $nargs, $args)";
200
+
201
+	# Assign return values.
202
+	my $body = "";
203
+	my $failexpr = "";
204
+	my @ret = ("_", "_", "_");
205
+	my @pout= ();
206
+	my $do_errno = 0;
207
+	for(my $i=0; $i<@out; $i++) {
208
+		my $p = $out[$i];
209
+		my ($name, $type) = parseparam($p);
210
+		my $reg = "";
211
+		if($name eq "err") {
212
+			$reg = "e1";
213
+			$ret[2] = $reg;
214
+			$do_errno = 1;
215
+		} else {
216
+			$reg = sprintf("r%d", $i);
217
+			$ret[$i] = $reg;
218
+		}
219
+		if($type eq "bool") {
220
+			$reg = "$reg != 0";
221
+		}
222
+		if($type eq "int64" && $_32bit ne "") {
223
+			# 64-bit number in r1:r0 or r0:r1.
224
+			if($i+2 > @out) {
225
+				print STDERR "$ARGV:$.: not enough registers for int64 return\n";
226
+			}
227
+			if($_32bit eq "big-endian") {
228
+				$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
229
+			} else {
230
+				$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
231
+			}
232
+			$ret[$i] = sprintf("r%d", $i);
233
+			$ret[$i+1] = sprintf("r%d", $i+1);
234
+		}
235
+		if($reg ne "e1") {
236
+			$body .= "\t$name = $type($reg)\n";
237
+		}
238
+	}
239
+	if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
240
+		$text .= "\t$call\n";
241
+	} else {
242
+		$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
243
+	}
244
+	$text .= $body;
245
+
246
+	if ($do_errno) {
247
+		$text .= "\tif e1 != 0 {\n";
248
+		$text .= "\t\terr = e1\n";
249
+		$text .= "\t}\n";
250
+	}
251
+	$text .= "\treturn\n";
252
+	$text .= "}\n";
253
+}
254
+
255
+if($errors) {
256
+	exit 1;
257
+}
258
+
259
+print <<EOF;
260
+// $cmdline
261
+// Code generated by the command above; see README.md. DO NOT EDIT.
262
+
263
+// +build $tags
264
+
265
+package $package
266
+
267
+import (
268
+	"syscall"
269
+	"unsafe"
270
+)
271
+EOF
272
+
273
+print "import \"golang.org/x/sys/unix\"\n" if $package ne "unix";
274
+
275
+my $vardecls = "\t" . join(",\n\t", @vars);
276
+$vardecls .= " syscallFunc";
277
+
278
+chomp($_=<<EOF);
279
+
280
+$dynimports
281
+$linknames
282
+var (
283
+$vardecls
284
+)
285
+
286
+$text
287
+EOF
288
+print $_;
289
+exit 0;

+ 264
- 0
vendor/src/golang.org/x/sys/unix/mksysctl_openbsd.pl Ver fichero

@@ -0,0 +1,264 @@
1
+#!/usr/bin/env perl
2
+
3
+# Copyright 2011 The Go Authors. All rights reserved.
4
+# Use of this source code is governed by a BSD-style
5
+# license that can be found in the LICENSE file.
6
+
7
+#
8
+# Parse the header files for OpenBSD and generate a Go usable sysctl MIB.
9
+#
10
+# Build a MIB with each entry being an array containing the level, type and
11
+# a hash that will contain additional entries if the current entry is a node.
12
+# We then walk this MIB and create a flattened sysctl name to OID hash.
13
+#
14
+
15
+use strict;
16
+
17
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
18
+	print STDERR "GOARCH or GOOS not defined in environment\n";
19
+	exit 1;
20
+}
21
+
22
+my $debug = 0;
23
+my %ctls = ();
24
+
25
+my @headers = qw (
26
+	sys/sysctl.h
27
+	sys/socket.h
28
+	sys/tty.h
29
+	sys/malloc.h
30
+	sys/mount.h
31
+	sys/namei.h
32
+	sys/sem.h
33
+	sys/shm.h
34
+	sys/vmmeter.h
35
+	uvm/uvm_param.h
36
+	uvm/uvm_swap_encrypt.h
37
+	ddb/db_var.h
38
+	net/if.h
39
+	net/if_pfsync.h
40
+	net/pipex.h
41
+	netinet/in.h
42
+	netinet/icmp_var.h
43
+	netinet/igmp_var.h
44
+	netinet/ip_ah.h
45
+	netinet/ip_carp.h
46
+	netinet/ip_divert.h
47
+	netinet/ip_esp.h
48
+	netinet/ip_ether.h
49
+	netinet/ip_gre.h
50
+	netinet/ip_ipcomp.h
51
+	netinet/ip_ipip.h
52
+	netinet/pim_var.h
53
+	netinet/tcp_var.h
54
+	netinet/udp_var.h
55
+	netinet6/in6.h
56
+	netinet6/ip6_divert.h
57
+	netinet6/pim6_var.h
58
+	netinet/icmp6.h
59
+	netmpls/mpls.h
60
+);
61
+
62
+my @ctls = qw (
63
+	kern
64
+	vm
65
+	fs
66
+	net
67
+	#debug				# Special handling required
68
+	hw
69
+	#machdep			# Arch specific
70
+	user
71
+	ddb
72
+	#vfs				# Special handling required
73
+	fs.posix
74
+	kern.forkstat
75
+	kern.intrcnt
76
+	kern.malloc
77
+	kern.nchstats
78
+	kern.seminfo
79
+	kern.shminfo
80
+	kern.timecounter
81
+	kern.tty
82
+	kern.watchdog
83
+	net.bpf
84
+	net.ifq
85
+	net.inet
86
+	net.inet.ah
87
+	net.inet.carp
88
+	net.inet.divert
89
+	net.inet.esp
90
+	net.inet.etherip
91
+	net.inet.gre
92
+	net.inet.icmp
93
+	net.inet.igmp
94
+	net.inet.ip
95
+	net.inet.ip.ifq
96
+	net.inet.ipcomp
97
+	net.inet.ipip
98
+	net.inet.mobileip
99
+	net.inet.pfsync
100
+	net.inet.pim
101
+	net.inet.tcp
102
+	net.inet.udp
103
+	net.inet6
104
+	net.inet6.divert
105
+	net.inet6.ip6
106
+	net.inet6.icmp6
107
+	net.inet6.pim6
108
+	net.inet6.tcp6
109
+	net.inet6.udp6
110
+	net.mpls
111
+	net.mpls.ifq
112
+	net.key
113
+	net.pflow
114
+	net.pfsync
115
+	net.pipex
116
+	net.rt
117
+	vm.swapencrypt
118
+	#vfsgenctl			# Special handling required
119
+);
120
+
121
+# Node name "fixups"
122
+my %ctl_map = (
123
+	"ipproto" => "net.inet",
124
+	"net.inet.ipproto" => "net.inet",
125
+	"net.inet6.ipv6proto" => "net.inet6",
126
+	"net.inet6.ipv6" => "net.inet6.ip6",
127
+	"net.inet.icmpv6" => "net.inet6.icmp6",
128
+	"net.inet6.divert6" => "net.inet6.divert",
129
+	"net.inet6.tcp6" => "net.inet.tcp",
130
+	"net.inet6.udp6" => "net.inet.udp",
131
+	"mpls" => "net.mpls",
132
+	"swpenc" => "vm.swapencrypt"
133
+);
134
+
135
+# Node mappings
136
+my %node_map = (
137
+	"net.inet.ip.ifq" => "net.ifq",
138
+	"net.inet.pfsync" => "net.pfsync",
139
+	"net.mpls.ifq" => "net.ifq"
140
+);
141
+
142
+my $ctlname;
143
+my %mib = ();
144
+my %sysctl = ();
145
+my $node;
146
+
147
+sub debug() {
148
+	print STDERR "$_[0]\n" if $debug;
149
+}
150
+
151
+# Walk the MIB and build a sysctl name to OID mapping.
152
+sub build_sysctl() {
153
+	my ($node, $name, $oid) = @_;
154
+	my %node = %{$node};
155
+	my @oid = @{$oid};
156
+
157
+	foreach my $key (sort keys %node) {
158
+		my @node = @{$node{$key}};
159
+		my $nodename = $name.($name ne '' ? '.' : '').$key;
160
+		my @nodeoid = (@oid, $node[0]);
161
+		if ($node[1] eq 'CTLTYPE_NODE') {
162
+			if (exists $node_map{$nodename}) {
163
+				$node = \%mib;
164
+				$ctlname = $node_map{$nodename};
165
+				foreach my $part (split /\./, $ctlname) {
166
+					$node = \%{@{$$node{$part}}[2]};
167
+				}
168
+			} else {
169
+				$node = $node[2];
170
+			}
171
+			&build_sysctl($node, $nodename, \@nodeoid);
172
+		} elsif ($node[1] ne '') {
173
+			$sysctl{$nodename} = \@nodeoid;
174
+		}
175
+	}
176
+}
177
+
178
+foreach my $ctl (@ctls) {
179
+	$ctls{$ctl} = $ctl;
180
+}
181
+
182
+# Build MIB
183
+foreach my $header (@headers) {
184
+	&debug("Processing $header...");
185
+	open HEADER, "/usr/include/$header" ||
186
+	    print STDERR "Failed to open $header\n";
187
+	while (<HEADER>) {
188
+		if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ ||
189
+		    $_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ ||
190
+		    $_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) {
191
+			if ($1 eq 'CTL_NAMES') {
192
+				# Top level.
193
+				$node = \%mib;
194
+			} else {
195
+				# Node.
196
+				my $nodename = lc($2);
197
+				if ($header =~ /^netinet\//) {
198
+					$ctlname = "net.inet.$nodename";
199
+				} elsif ($header =~ /^netinet6\//) {
200
+					$ctlname = "net.inet6.$nodename";
201
+				} elsif ($header =~ /^net\//) {
202
+					$ctlname = "net.$nodename";
203
+				} else {
204
+					$ctlname = "$nodename";
205
+					$ctlname =~ s/^(fs|net|kern)_/$1\./;
206
+				}
207
+				if (exists $ctl_map{$ctlname}) {
208
+					$ctlname = $ctl_map{$ctlname};
209
+				}
210
+				if (not exists $ctls{$ctlname}) {
211
+					&debug("Ignoring $ctlname...");
212
+					next;
213
+				}
214
+
215
+				# Walk down from the top of the MIB.
216
+				$node = \%mib;
217
+				foreach my $part (split /\./, $ctlname) {
218
+					if (not exists $$node{$part}) {
219
+						&debug("Missing node $part");
220
+						$$node{$part} = [ 0, '', {} ];
221
+					}
222
+					$node = \%{@{$$node{$part}}[2]};
223
+				}
224
+			}
225
+
226
+			# Populate current node with entries.
227
+			my $i = -1;
228
+			while (defined($_) && $_ !~ /^}/) {
229
+				$_ = <HEADER>;
230
+				$i++ if $_ =~ /{.*}/;
231
+				next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/;
232
+				$$node{$1} = [ $i, $2, {} ];
233
+			}
234
+		}
235
+	}
236
+	close HEADER;
237
+}
238
+
239
+&build_sysctl(\%mib, "", []);
240
+
241
+print <<EOF;
242
+// mksysctl_openbsd.pl
243
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
244
+
245
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
246
+
247
+package unix;
248
+
249
+type mibentry struct {
250
+	ctlname string
251
+	ctloid []_C_int
252
+}
253
+
254
+var sysctlMib = []mibentry {
255
+EOF
256
+
257
+foreach my $name (sort keys %sysctl) {
258
+	my @oid = @{$sysctl{$name}};
259
+	print "\t{ \"$name\", []_C_int{ ", join(', ', @oid), " } }, \n";
260
+}
261
+
262
+print <<EOF;
263
+}
264
+EOF

+ 39
- 0
vendor/src/golang.org/x/sys/unix/mksysnum_darwin.pl Ver fichero

@@ -0,0 +1,39 @@
1
+#!/usr/bin/env perl
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+#
6
+# Generate system call table for Darwin from sys/syscall.h
7
+
8
+use strict;
9
+
10
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
11
+	print STDERR "GOARCH or GOOS not defined in environment\n";
12
+	exit 1;
13
+}
14
+
15
+my $command = "mksysnum_darwin.pl " . join(' ', @ARGV);
16
+
17
+print <<EOF;
18
+// $command
19
+// Code generated by the command above; see README.md. DO NOT EDIT.
20
+
21
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
22
+
23
+package unix
24
+
25
+const (
26
+EOF
27
+
28
+while(<>){
29
+	if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){
30
+		my $name = $1;
31
+		my $num = $2;
32
+		$name =~ y/a-z/A-Z/;
33
+		print "	SYS_$name = $num;"
34
+	}
35
+}
36
+
37
+print <<EOF;
38
+)
39
+EOF

+ 50
- 0
vendor/src/golang.org/x/sys/unix/mksysnum_dragonfly.pl Ver fichero

@@ -0,0 +1,50 @@
1
+#!/usr/bin/env perl
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+#
6
+# Generate system call table for DragonFly from master list
7
+# (for example, /usr/src/sys/kern/syscalls.master).
8
+
9
+use strict;
10
+
11
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
12
+	print STDERR "GOARCH or GOOS not defined in environment\n";
13
+	exit 1;
14
+}
15
+
16
+my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV);
17
+
18
+print <<EOF;
19
+// $command
20
+// Code generated by the command above; see README.md. DO NOT EDIT.
21
+
22
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
23
+
24
+package unix
25
+
26
+const (
27
+EOF
28
+
29
+while(<>){
30
+	if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){
31
+		my $num = $1;
32
+		my $proto = $2;
33
+		my $name = "SYS_$3";
34
+		$name =~ y/a-z/A-Z/;
35
+
36
+		# There are multiple entries for enosys and nosys, so comment them out.
37
+		if($name =~ /^SYS_E?NOSYS$/){
38
+			$name = "// $name";
39
+		}
40
+		if($name eq 'SYS_SYS_EXIT'){
41
+			$name = 'SYS_EXIT';
42
+		}
43
+
44
+		print "	$name = $num;  // $proto\n";
45
+	}
46
+}
47
+
48
+print <<EOF;
49
+)
50
+EOF

+ 50
- 0
vendor/src/golang.org/x/sys/unix/mksysnum_freebsd.pl Ver fichero

@@ -0,0 +1,50 @@
1
+#!/usr/bin/env perl
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+#
6
+# Generate system call table for FreeBSD from master list
7
+# (for example, /usr/src/sys/kern/syscalls.master).
8
+
9
+use strict;
10
+
11
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
12
+	print STDERR "GOARCH or GOOS not defined in environment\n";
13
+	exit 1;
14
+}
15
+
16
+my $command = "mksysnum_freebsd.pl " . join(' ', @ARGV);
17
+
18
+print <<EOF;
19
+// $command
20
+// Code generated by the command above; see README.md. DO NOT EDIT.
21
+
22
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
23
+
24
+package unix
25
+
26
+const (
27
+EOF
28
+
29
+while(<>){
30
+	if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
31
+		my $num = $1;
32
+		my $proto = $2;
33
+		my $name = "SYS_$3";
34
+		$name =~ y/a-z/A-Z/;
35
+
36
+		# There are multiple entries for enosys and nosys, so comment them out.
37
+		if($name =~ /^SYS_E?NOSYS$/){
38
+			$name = "// $name";
39
+		}
40
+		if($name eq 'SYS_SYS_EXIT'){
41
+			$name = 'SYS_EXIT';
42
+		}
43
+
44
+		print "	$name = $num;  // $proto\n";
45
+	}
46
+}
47
+
48
+print <<EOF;
49
+)
50
+EOF

+ 58
- 0
vendor/src/golang.org/x/sys/unix/mksysnum_netbsd.pl Ver fichero

@@ -0,0 +1,58 @@
1
+#!/usr/bin/env perl
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+#
6
+# Generate system call table for OpenBSD from master list
7
+# (for example, /usr/src/sys/kern/syscalls.master).
8
+
9
+use strict;
10
+
11
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
12
+	print STDERR "GOARCH or GOOS not defined in environment\n";
13
+	exit 1;
14
+}
15
+
16
+my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV);
17
+
18
+print <<EOF;
19
+// $command
20
+// Code generated by the command above; see README.md. DO NOT EDIT.
21
+
22
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
23
+
24
+package unix
25
+
26
+const (
27
+EOF
28
+
29
+my $line = '';
30
+while(<>){
31
+	if($line =~ /^(.*)\\$/) {
32
+		# Handle continuation
33
+		$line = $1;
34
+		$_ =~ s/^\s+//;
35
+		$line .= $_;
36
+	} else {
37
+		# New line
38
+		$line = $_;
39
+	}
40
+	next if $line =~ /\\$/;
41
+	if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
42
+		my $num = $1;
43
+		my $proto = $6;
44
+		my $compat = $8;
45
+		my $name = "$7_$9";
46
+
47
+		$name = "$7_$11" if $11 ne '';
48
+		$name =~ y/a-z/A-Z/;
49
+
50
+		if($compat eq '' || $compat eq '13' || $compat eq '30' || $compat eq '50') {
51
+			print "	$name = $num;  // $proto\n";
52
+		}
53
+	}
54
+}
55
+
56
+print <<EOF;
57
+)
58
+EOF

+ 50
- 0
vendor/src/golang.org/x/sys/unix/mksysnum_openbsd.pl Ver fichero

@@ -0,0 +1,50 @@
1
+#!/usr/bin/env perl
2
+# Copyright 2009 The Go Authors. All rights reserved.
3
+# Use of this source code is governed by a BSD-style
4
+# license that can be found in the LICENSE file.
5
+#
6
+# Generate system call table for OpenBSD from master list
7
+# (for example, /usr/src/sys/kern/syscalls.master).
8
+
9
+use strict;
10
+
11
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
12
+	print STDERR "GOARCH or GOOS not defined in environment\n";
13
+	exit 1;
14
+}
15
+
16
+my $command = "mksysnum_openbsd.pl " . join(' ', @ARGV);
17
+
18
+print <<EOF;
19
+// $command
20
+// Code generated by the command above; see README.md. DO NOT EDIT.
21
+
22
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
23
+
24
+package unix
25
+
26
+const (
27
+EOF
28
+
29
+while(<>){
30
+	if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){
31
+		my $num = $1;
32
+		my $proto = $3;
33
+		my $name = $4;
34
+		$name =~ y/a-z/A-Z/;
35
+
36
+		# There are multiple entries for enosys and nosys, so comment them out.
37
+		if($name =~ /^SYS_E?NOSYS$/){
38
+			$name = "// $name";
39
+		}
40
+		if($name eq 'SYS_SYS_EXIT'){
41
+			$name = 'SYS_EXIT';
42
+		}
43
+
44
+		print "	$name = $num;  // $proto\n";
45
+	}
46
+}
47
+
48
+print <<EOF;
49
+)
50
+EOF

+ 35
- 0
vendor/src/golang.org/x/sys/unix/mmap_unix_test.go Ver fichero

@@ -0,0 +1,35 @@
1
+// Copyright 2014 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
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+package unix_test
8
+
9
+import (
10
+	"testing"
11
+
12
+	"golang.org/x/sys/unix"
13
+)
14
+
15
+func TestMmap(t *testing.T) {
16
+	b, err := unix.Mmap(-1, 0, unix.Getpagesize(), unix.PROT_NONE, unix.MAP_ANON|unix.MAP_PRIVATE)
17
+	if err != nil {
18
+		t.Fatalf("Mmap: %v", err)
19
+	}
20
+	if err := unix.Mprotect(b, unix.PROT_READ|unix.PROT_WRITE); err != nil {
21
+		t.Fatalf("Mprotect: %v", err)
22
+	}
23
+
24
+	b[0] = 42
25
+
26
+	if err := unix.Msync(b, unix.MS_SYNC); err != nil {
27
+		t.Fatalf("Msync: %v", err)
28
+	}
29
+	if err := unix.Madvise(b, unix.MADV_DONTNEED); err != nil {
30
+		t.Fatalf("Madvise: %v", err)
31
+	}
32
+	if err := unix.Munmap(b); err != nil {
33
+		t.Fatalf("Munmap: %v", err)
34
+	}
35
+}

+ 38
- 0
vendor/src/golang.org/x/sys/unix/openbsd_pledge.go Ver fichero

@@ -0,0 +1,38 @@
1
+// Copyright 2016 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
+// +build openbsd
6
+// +build 386 amd64 arm
7
+
8
+package unix
9
+
10
+import (
11
+	"syscall"
12
+	"unsafe"
13
+)
14
+
15
+const (
16
+	SYS_PLEDGE = 108
17
+)
18
+
19
+// Pledge implements the pledge syscall. For more information see pledge(2).
20
+func Pledge(promises string, paths []string) error {
21
+	promisesPtr, err := syscall.BytePtrFromString(promises)
22
+	if err != nil {
23
+		return err
24
+	}
25
+	promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil)
26
+	if paths != nil {
27
+		var pathsPtr []*byte
28
+		if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil {
29
+			return err
30
+		}
31
+		pathsUnsafe = unsafe.Pointer(&pathsPtr[0])
32
+	}
33
+	_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0)
34
+	if e != 0 {
35
+		return e
36
+	}
37
+	return nil
38
+}

+ 113
- 0
vendor/src/golang.org/x/sys/unix/openbsd_test.go Ver fichero

@@ -0,0 +1,113 @@
1
+// Copyright 2016 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
+// +build openbsd
6
+
7
+// This, on the face of it, bizarre testing mechanism is necessary because
8
+// the only reliable way to gauge whether or not a pledge(2) call has succeeded
9
+// is that the program has been killed as a result of breaking its pledge.
10
+
11
+package unix_test
12
+
13
+import (
14
+	"flag"
15
+	"fmt"
16
+	"io/ioutil"
17
+	"os"
18
+	"os/exec"
19
+	"path/filepath"
20
+	"testing"
21
+
22
+	"golang.org/x/sys/unix"
23
+)
24
+
25
+type testProc struct {
26
+	fn      func()       // should always exit instead of returning
27
+	cleanup func() error // for instance, delete coredumps from testing pledge
28
+	success bool         // whether zero-exit means success or failure
29
+}
30
+
31
+var (
32
+	testProcs = map[string]testProc{}
33
+	procName  = ""
34
+)
35
+
36
+const (
37
+	optName = "sys-unix-internal-procname"
38
+)
39
+
40
+func init() {
41
+	flag.StringVar(&procName, optName, "", "internal use only")
42
+}
43
+
44
+// testCmd generates a proper command that, when executed, runs the test
45
+// corresponding to the given key.
46
+func testCmd(procName string) (*exec.Cmd, error) {
47
+	exe, err := filepath.Abs(os.Args[0])
48
+	if err != nil {
49
+		return nil, err
50
+	}
51
+	cmd := exec.Command(exe, "-"+optName+"="+procName)
52
+	cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
53
+	return cmd, nil
54
+}
55
+
56
+// ExitsCorrectly is a comprehensive, one-line-of-use wrapper for testing
57
+// a testProc with a key.
58
+func ExitsCorrectly(procName string, t *testing.T) {
59
+	s := testProcs[procName]
60
+	c, err := testCmd(procName)
61
+	defer func() {
62
+		if s.cleanup() != nil {
63
+			t.Fatalf("Failed to run cleanup for %s", procName)
64
+		}
65
+	}()
66
+	if err != nil {
67
+		t.Fatalf("Failed to construct command for %s", procName)
68
+	}
69
+	if (c.Run() == nil) != s.success {
70
+		result := "succeed"
71
+		if !s.success {
72
+			result = "fail"
73
+		}
74
+		t.Fatalf("Process did not %s when it was supposed to", result)
75
+	}
76
+}
77
+
78
+func TestMain(m *testing.M) {
79
+	flag.Parse()
80
+	if procName != "" {
81
+		testProcs[procName].fn()
82
+	}
83
+	os.Exit(m.Run())
84
+}
85
+
86
+// For example, add a test for pledge.
87
+func init() {
88
+	testProcs["pledge"] = testProc{
89
+		func() {
90
+			fmt.Println(unix.Pledge("", nil))
91
+			os.Exit(0)
92
+		},
93
+		func() error {
94
+			files, err := ioutil.ReadDir(".")
95
+			if err != nil {
96
+				return err
97
+			}
98
+			for _, file := range files {
99
+				if filepath.Ext(file.Name()) == ".core" {
100
+					if err := os.Remove(file.Name()); err != nil {
101
+						return err
102
+					}
103
+				}
104
+			}
105
+			return nil
106
+		},
107
+		false,
108
+	}
109
+}
110
+
111
+func TestPledge(t *testing.T) {
112
+	ExitsCorrectly("pledge", t)
113
+}

+ 15
- 0
vendor/src/golang.org/x/sys/unix/pagesize_unix.go Ver fichero

@@ -0,0 +1,15 @@
1
+// Copyright 2017 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
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+// For Unix, get the pagesize from the runtime.
8
+
9
+package unix
10
+
11
+import "syscall"
12
+
13
+func Getpagesize() int {
14
+	return syscall.Getpagesize()
15
+}

+ 30
- 0
vendor/src/golang.org/x/sys/unix/race.go Ver fichero

@@ -0,0 +1,30 @@
1
+// Copyright 2012 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
+// +build darwin,race linux,race freebsd,race
6
+
7
+package unix
8
+
9
+import (
10
+	"runtime"
11
+	"unsafe"
12
+)
13
+
14
+const raceenabled = true
15
+
16
+func raceAcquire(addr unsafe.Pointer) {
17
+	runtime.RaceAcquire(addr)
18
+}
19
+
20
+func raceReleaseMerge(addr unsafe.Pointer) {
21
+	runtime.RaceReleaseMerge(addr)
22
+}
23
+
24
+func raceReadRange(addr unsafe.Pointer, len int) {
25
+	runtime.RaceReadRange(addr, len)
26
+}
27
+
28
+func raceWriteRange(addr unsafe.Pointer, len int) {
29
+	runtime.RaceWriteRange(addr, len)
30
+}

+ 25
- 0
vendor/src/golang.org/x/sys/unix/race0.go Ver fichero

@@ -0,0 +1,25 @@
1
+// Copyright 2012 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
+// +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly
6
+
7
+package unix
8
+
9
+import (
10
+	"unsafe"
11
+)
12
+
13
+const raceenabled = false
14
+
15
+func raceAcquire(addr unsafe.Pointer) {
16
+}
17
+
18
+func raceReleaseMerge(addr unsafe.Pointer) {
19
+}
20
+
21
+func raceReadRange(addr unsafe.Pointer, len int) {
22
+}
23
+
24
+func raceWriteRange(addr unsafe.Pointer, len int) {
25
+}

+ 36
- 0
vendor/src/golang.org/x/sys/unix/sockcmsg_linux.go Ver fichero

@@ -0,0 +1,36 @@
1
+// Copyright 2011 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
+// Socket control messages
6
+
7
+package unix
8
+
9
+import "unsafe"
10
+
11
+// UnixCredentials encodes credentials into a socket control message
12
+// for sending to another process. This can be used for
13
+// authentication.
14
+func UnixCredentials(ucred *Ucred) []byte {
15
+	b := make([]byte, CmsgSpace(SizeofUcred))
16
+	h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
17
+	h.Level = SOL_SOCKET
18
+	h.Type = SCM_CREDENTIALS
19
+	h.SetLen(CmsgLen(SizeofUcred))
20
+	*((*Ucred)(cmsgData(h))) = *ucred
21
+	return b
22
+}
23
+
24
+// ParseUnixCredentials decodes a socket control message that contains
25
+// credentials in a Ucred structure. To receive such a message, the
26
+// SO_PASSCRED option must be enabled on the socket.
27
+func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) {
28
+	if m.Header.Level != SOL_SOCKET {
29
+		return nil, EINVAL
30
+	}
31
+	if m.Header.Type != SCM_CREDENTIALS {
32
+		return nil, EINVAL
33
+	}
34
+	ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
35
+	return &ucred, nil
36
+}

+ 104
- 0
vendor/src/golang.org/x/sys/unix/sockcmsg_unix.go Ver fichero

@@ -0,0 +1,104 @@
1
+// Copyright 2011 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
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+// Socket control messages
8
+
9
+package unix
10
+
11
+import "unsafe"
12
+
13
+// Round the length of a raw sockaddr up to align it properly.
14
+func cmsgAlignOf(salen int) int {
15
+	salign := sizeofPtr
16
+	// NOTE: It seems like 64-bit Darwin, DragonFly BSD and
17
+	// Solaris kernels still require 32-bit aligned access to
18
+	// network subsystem.
19
+	if darwin64Bit || dragonfly64Bit || solaris64Bit {
20
+		salign = 4
21
+	}
22
+	return (salen + salign - 1) & ^(salign - 1)
23
+}
24
+
25
+// CmsgLen returns the value to store in the Len field of the Cmsghdr
26
+// structure, taking into account any necessary alignment.
27
+func CmsgLen(datalen int) int {
28
+	return cmsgAlignOf(SizeofCmsghdr) + datalen
29
+}
30
+
31
+// CmsgSpace returns the number of bytes an ancillary element with
32
+// payload of the passed data length occupies.
33
+func CmsgSpace(datalen int) int {
34
+	return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
35
+}
36
+
37
+func cmsgData(h *Cmsghdr) unsafe.Pointer {
38
+	return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)))
39
+}
40
+
41
+// SocketControlMessage represents a socket control message.
42
+type SocketControlMessage struct {
43
+	Header Cmsghdr
44
+	Data   []byte
45
+}
46
+
47
+// ParseSocketControlMessage parses b as an array of socket control
48
+// messages.
49
+func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
50
+	var msgs []SocketControlMessage
51
+	i := 0
52
+	for i+CmsgLen(0) <= len(b) {
53
+		h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
54
+		if err != nil {
55
+			return nil, err
56
+		}
57
+		m := SocketControlMessage{Header: *h, Data: dbuf}
58
+		msgs = append(msgs, m)
59
+		i += cmsgAlignOf(int(h.Len))
60
+	}
61
+	return msgs, nil
62
+}
63
+
64
+func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
65
+	h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
66
+	if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) {
67
+		return nil, nil, EINVAL
68
+	}
69
+	return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
70
+}
71
+
72
+// UnixRights encodes a set of open file descriptors into a socket
73
+// control message for sending to another process.
74
+func UnixRights(fds ...int) []byte {
75
+	datalen := len(fds) * 4
76
+	b := make([]byte, CmsgSpace(datalen))
77
+	h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
78
+	h.Level = SOL_SOCKET
79
+	h.Type = SCM_RIGHTS
80
+	h.SetLen(CmsgLen(datalen))
81
+	data := cmsgData(h)
82
+	for _, fd := range fds {
83
+		*(*int32)(data) = int32(fd)
84
+		data = unsafe.Pointer(uintptr(data) + 4)
85
+	}
86
+	return b
87
+}
88
+
89
+// ParseUnixRights decodes a socket control message that contains an
90
+// integer array of open file descriptors from another process.
91
+func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
92
+	if m.Header.Level != SOL_SOCKET {
93
+		return nil, EINVAL
94
+	}
95
+	if m.Header.Type != SCM_RIGHTS {
96
+		return nil, EINVAL
97
+	}
98
+	fds := make([]int, len(m.Data)>>2)
99
+	for i, j := 0, 0; i < len(m.Data); i += 4 {
100
+		fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
101
+		j++
102
+	}
103
+	return fds, nil
104
+}

+ 26
- 0
vendor/src/golang.org/x/sys/unix/str.go Ver fichero

@@ -0,0 +1,26 @@
1
+// Copyright 2009 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
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+package unix
8
+
9
+func itoa(val int) string { // do it here rather than with fmt to avoid dependency
10
+	if val < 0 {
11
+		return "-" + uitoa(uint(-val))
12
+	}
13
+	return uitoa(uint(val))
14
+}
15
+
16
+func uitoa(val uint) string {
17
+	var buf [32]byte // big enough for int64
18
+	i := len(buf) - 1
19
+	for val >= 10 {
20
+		buf[i] = byte(val%10 + '0')
21
+		i--
22
+		val /= 10
23
+	}
24
+	buf[i] = byte(val + '0')
25
+	return string(buf[i:])
26
+}

+ 51
- 0
vendor/src/golang.org/x/sys/unix/syscall.go Ver fichero

@@ -0,0 +1,51 @@
1
+// Copyright 2009 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
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+// Package unix contains an interface to the low-level operating system
8
+// primitives. OS details vary depending on the underlying system, and
9
+// by default, godoc will display OS-specific documentation for the current
10
+// system. If you want godoc to display OS documentation for another
11
+// system, set $GOOS and $GOARCH to the desired system. For example, if
12
+// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
13
+// to freebsd and $GOARCH to arm.
14
+// The primary use of this package is inside other packages that provide a more
15
+// portable interface to the system, such as "os", "time" and "net".  Use
16
+// those packages rather than this one if you can.
17
+// For details of the functions and data types in this package consult
18
+// the manuals for the appropriate operating system.
19
+// These calls return err == nil to indicate success; otherwise
20
+// err represents an operating system error describing the failure and
21
+// holds a value of type syscall.Errno.
22
+package unix // import "golang.org/x/sys/unix"
23
+
24
+// ByteSliceFromString returns a NUL-terminated slice of bytes
25
+// containing the text of s. If s contains a NUL byte at any
26
+// location, it returns (nil, EINVAL).
27
+func ByteSliceFromString(s string) ([]byte, error) {
28
+	for i := 0; i < len(s); i++ {
29
+		if s[i] == 0 {
30
+			return nil, EINVAL
31
+		}
32
+	}
33
+	a := make([]byte, len(s)+1)
34
+	copy(a, s)
35
+	return a, nil
36
+}
37
+
38
+// BytePtrFromString returns a pointer to a NUL-terminated array of
39
+// bytes containing the text of s. If s contains a NUL byte at any
40
+// location, it returns (nil, EINVAL).
41
+func BytePtrFromString(s string) (*byte, error) {
42
+	a, err := ByteSliceFromString(s)
43
+	if err != nil {
44
+		return nil, err
45
+	}
46
+	return &a[0], nil
47
+}
48
+
49
+// Single-word zero for use when we need a valid pointer to 0 bytes.
50
+// See mkunix.pl.
51
+var _zero uintptr

+ 653
- 0
vendor/src/golang.org/x/sys/unix/syscall_bsd.go Ver fichero

@@ -0,0 +1,653 @@
1
+// Copyright 2009 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
+// +build darwin dragonfly freebsd netbsd openbsd
6
+
7
+// BSD system call wrappers shared by *BSD based systems
8
+// including OS X (Darwin) and FreeBSD.  Like the other
9
+// syscall_*.go files it is compiled as Go code but also
10
+// used as input to mksyscall which parses the //sys
11
+// lines and generates system call stubs.
12
+
13
+package unix
14
+
15
+import (
16
+	"runtime"
17
+	"syscall"
18
+	"unsafe"
19
+)
20
+
21
+/*
22
+ * Wrapped
23
+ */
24
+
25
+//sysnb	getgroups(ngid int, gid *_Gid_t) (n int, err error)
26
+//sysnb	setgroups(ngid int, gid *_Gid_t) (err error)
27
+
28
+func Getgroups() (gids []int, err error) {
29
+	n, err := getgroups(0, nil)
30
+	if err != nil {
31
+		return nil, err
32
+	}
33
+	if n == 0 {
34
+		return nil, nil
35
+	}
36
+
37
+	// Sanity check group count. Max is 16 on BSD.
38
+	if n < 0 || n > 1000 {
39
+		return nil, EINVAL
40
+	}
41
+
42
+	a := make([]_Gid_t, n)
43
+	n, err = getgroups(n, &a[0])
44
+	if err != nil {
45
+		return nil, err
46
+	}
47
+	gids = make([]int, n)
48
+	for i, v := range a[0:n] {
49
+		gids[i] = int(v)
50
+	}
51
+	return
52
+}
53
+
54
+func Setgroups(gids []int) (err error) {
55
+	if len(gids) == 0 {
56
+		return setgroups(0, nil)
57
+	}
58
+
59
+	a := make([]_Gid_t, len(gids))
60
+	for i, v := range gids {
61
+		a[i] = _Gid_t(v)
62
+	}
63
+	return setgroups(len(a), &a[0])
64
+}
65
+
66
+func ReadDirent(fd int, buf []byte) (n int, err error) {
67
+	// Final argument is (basep *uintptr) and the syscall doesn't take nil.
68
+	// 64 bits should be enough. (32 bits isn't even on 386). Since the
69
+	// actual system call is getdirentries64, 64 is a good guess.
70
+	// TODO(rsc): Can we use a single global basep for all calls?
71
+	var base = (*uintptr)(unsafe.Pointer(new(uint64)))
72
+	return Getdirentries(fd, buf, base)
73
+}
74
+
75
+// Wait status is 7 bits at bottom, either 0 (exited),
76
+// 0x7F (stopped), or a signal number that caused an exit.
77
+// The 0x80 bit is whether there was a core dump.
78
+// An extra number (exit code, signal causing a stop)
79
+// is in the high bits.
80
+
81
+type WaitStatus uint32
82
+
83
+const (
84
+	mask  = 0x7F
85
+	core  = 0x80
86
+	shift = 8
87
+
88
+	exited  = 0
89
+	stopped = 0x7F
90
+)
91
+
92
+func (w WaitStatus) Exited() bool { return w&mask == exited }
93
+
94
+func (w WaitStatus) ExitStatus() int {
95
+	if w&mask != exited {
96
+		return -1
97
+	}
98
+	return int(w >> shift)
99
+}
100
+
101
+func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
102
+
103
+func (w WaitStatus) Signal() syscall.Signal {
104
+	sig := syscall.Signal(w & mask)
105
+	if sig == stopped || sig == 0 {
106
+		return -1
107
+	}
108
+	return sig
109
+}
110
+
111
+func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
112
+
113
+func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
114
+
115
+func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
116
+
117
+func (w WaitStatus) StopSignal() syscall.Signal {
118
+	if !w.Stopped() {
119
+		return -1
120
+	}
121
+	return syscall.Signal(w>>shift) & 0xFF
122
+}
123
+
124
+func (w WaitStatus) TrapCause() int { return -1 }
125
+
126
+//sys	wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error)
127
+
128
+func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
129
+	var status _C_int
130
+	wpid, err = wait4(pid, &status, options, rusage)
131
+	if wstatus != nil {
132
+		*wstatus = WaitStatus(status)
133
+	}
134
+	return
135
+}
136
+
137
+//sys	accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
138
+//sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
139
+//sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
140
+//sysnb	socket(domain int, typ int, proto int) (fd int, err error)
141
+//sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
142
+//sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
143
+//sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
144
+//sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
145
+//sys	Shutdown(s int, how int) (err error)
146
+
147
+func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
148
+	if sa.Port < 0 || sa.Port > 0xFFFF {
149
+		return nil, 0, EINVAL
150
+	}
151
+	sa.raw.Len = SizeofSockaddrInet4
152
+	sa.raw.Family = AF_INET
153
+	p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
154
+	p[0] = byte(sa.Port >> 8)
155
+	p[1] = byte(sa.Port)
156
+	for i := 0; i < len(sa.Addr); i++ {
157
+		sa.raw.Addr[i] = sa.Addr[i]
158
+	}
159
+	return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
160
+}
161
+
162
+func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
163
+	if sa.Port < 0 || sa.Port > 0xFFFF {
164
+		return nil, 0, EINVAL
165
+	}
166
+	sa.raw.Len = SizeofSockaddrInet6
167
+	sa.raw.Family = AF_INET6
168
+	p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
169
+	p[0] = byte(sa.Port >> 8)
170
+	p[1] = byte(sa.Port)
171
+	sa.raw.Scope_id = sa.ZoneId
172
+	for i := 0; i < len(sa.Addr); i++ {
173
+		sa.raw.Addr[i] = sa.Addr[i]
174
+	}
175
+	return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
176
+}
177
+
178
+func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
179
+	name := sa.Name
180
+	n := len(name)
181
+	if n >= len(sa.raw.Path) || n == 0 {
182
+		return nil, 0, EINVAL
183
+	}
184
+	sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL
185
+	sa.raw.Family = AF_UNIX
186
+	for i := 0; i < n; i++ {
187
+		sa.raw.Path[i] = int8(name[i])
188
+	}
189
+	return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
190
+}
191
+
192
+func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) {
193
+	if sa.Index == 0 {
194
+		return nil, 0, EINVAL
195
+	}
196
+	sa.raw.Len = sa.Len
197
+	sa.raw.Family = AF_LINK
198
+	sa.raw.Index = sa.Index
199
+	sa.raw.Type = sa.Type
200
+	sa.raw.Nlen = sa.Nlen
201
+	sa.raw.Alen = sa.Alen
202
+	sa.raw.Slen = sa.Slen
203
+	for i := 0; i < len(sa.raw.Data); i++ {
204
+		sa.raw.Data[i] = sa.Data[i]
205
+	}
206
+	return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil
207
+}
208
+
209
+func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
210
+	switch rsa.Addr.Family {
211
+	case AF_LINK:
212
+		pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa))
213
+		sa := new(SockaddrDatalink)
214
+		sa.Len = pp.Len
215
+		sa.Family = pp.Family
216
+		sa.Index = pp.Index
217
+		sa.Type = pp.Type
218
+		sa.Nlen = pp.Nlen
219
+		sa.Alen = pp.Alen
220
+		sa.Slen = pp.Slen
221
+		for i := 0; i < len(sa.Data); i++ {
222
+			sa.Data[i] = pp.Data[i]
223
+		}
224
+		return sa, nil
225
+
226
+	case AF_UNIX:
227
+		pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
228
+		if pp.Len < 2 || pp.Len > SizeofSockaddrUnix {
229
+			return nil, EINVAL
230
+		}
231
+		sa := new(SockaddrUnix)
232
+
233
+		// Some BSDs include the trailing NUL in the length, whereas
234
+		// others do not. Work around this by subtracting the leading
235
+		// family and len. The path is then scanned to see if a NUL
236
+		// terminator still exists within the length.
237
+		n := int(pp.Len) - 2 // subtract leading Family, Len
238
+		for i := 0; i < n; i++ {
239
+			if pp.Path[i] == 0 {
240
+				// found early NUL; assume Len included the NUL
241
+				// or was overestimating.
242
+				n = i
243
+				break
244
+			}
245
+		}
246
+		bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
247
+		sa.Name = string(bytes)
248
+		return sa, nil
249
+
250
+	case AF_INET:
251
+		pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
252
+		sa := new(SockaddrInet4)
253
+		p := (*[2]byte)(unsafe.Pointer(&pp.Port))
254
+		sa.Port = int(p[0])<<8 + int(p[1])
255
+		for i := 0; i < len(sa.Addr); i++ {
256
+			sa.Addr[i] = pp.Addr[i]
257
+		}
258
+		return sa, nil
259
+
260
+	case AF_INET6:
261
+		pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
262
+		sa := new(SockaddrInet6)
263
+		p := (*[2]byte)(unsafe.Pointer(&pp.Port))
264
+		sa.Port = int(p[0])<<8 + int(p[1])
265
+		sa.ZoneId = pp.Scope_id
266
+		for i := 0; i < len(sa.Addr); i++ {
267
+			sa.Addr[i] = pp.Addr[i]
268
+		}
269
+		return sa, nil
270
+	}
271
+	return nil, EAFNOSUPPORT
272
+}
273
+
274
+func Accept(fd int) (nfd int, sa Sockaddr, err error) {
275
+	var rsa RawSockaddrAny
276
+	var len _Socklen = SizeofSockaddrAny
277
+	nfd, err = accept(fd, &rsa, &len)
278
+	if err != nil {
279
+		return
280
+	}
281
+	if runtime.GOOS == "darwin" && len == 0 {
282
+		// Accepted socket has no address.
283
+		// This is likely due to a bug in xnu kernels,
284
+		// where instead of ECONNABORTED error socket
285
+		// is accepted, but has no address.
286
+		Close(nfd)
287
+		return 0, nil, ECONNABORTED
288
+	}
289
+	sa, err = anyToSockaddr(&rsa)
290
+	if err != nil {
291
+		Close(nfd)
292
+		nfd = 0
293
+	}
294
+	return
295
+}
296
+
297
+func Getsockname(fd int) (sa Sockaddr, err error) {
298
+	var rsa RawSockaddrAny
299
+	var len _Socklen = SizeofSockaddrAny
300
+	if err = getsockname(fd, &rsa, &len); err != nil {
301
+		return
302
+	}
303
+	// TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be
304
+	// reported upstream.
305
+	if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 {
306
+		rsa.Addr.Family = AF_UNIX
307
+		rsa.Addr.Len = SizeofSockaddrUnix
308
+	}
309
+	return anyToSockaddr(&rsa)
310
+}
311
+
312
+//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
313
+
314
+func GetsockoptByte(fd, level, opt int) (value byte, err error) {
315
+	var n byte
316
+	vallen := _Socklen(1)
317
+	err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
318
+	return n, err
319
+}
320
+
321
+func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
322
+	vallen := _Socklen(4)
323
+	err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
324
+	return value, err
325
+}
326
+
327
+func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
328
+	var value IPMreq
329
+	vallen := _Socklen(SizeofIPMreq)
330
+	err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
331
+	return &value, err
332
+}
333
+
334
+func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
335
+	var value IPv6Mreq
336
+	vallen := _Socklen(SizeofIPv6Mreq)
337
+	err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
338
+	return &value, err
339
+}
340
+
341
+func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
342
+	var value IPv6MTUInfo
343
+	vallen := _Socklen(SizeofIPv6MTUInfo)
344
+	err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
345
+	return &value, err
346
+}
347
+
348
+func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
349
+	var value ICMPv6Filter
350
+	vallen := _Socklen(SizeofICMPv6Filter)
351
+	err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
352
+	return &value, err
353
+}
354
+
355
+//sys   recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
356
+//sys   sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
357
+//sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
358
+
359
+func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
360
+	var msg Msghdr
361
+	var rsa RawSockaddrAny
362
+	msg.Name = (*byte)(unsafe.Pointer(&rsa))
363
+	msg.Namelen = uint32(SizeofSockaddrAny)
364
+	var iov Iovec
365
+	if len(p) > 0 {
366
+		iov.Base = (*byte)(unsafe.Pointer(&p[0]))
367
+		iov.SetLen(len(p))
368
+	}
369
+	var dummy byte
370
+	if len(oob) > 0 {
371
+		// receive at least one normal byte
372
+		if len(p) == 0 {
373
+			iov.Base = &dummy
374
+			iov.SetLen(1)
375
+		}
376
+		msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
377
+		msg.SetControllen(len(oob))
378
+	}
379
+	msg.Iov = &iov
380
+	msg.Iovlen = 1
381
+	if n, err = recvmsg(fd, &msg, flags); err != nil {
382
+		return
383
+	}
384
+	oobn = int(msg.Controllen)
385
+	recvflags = int(msg.Flags)
386
+	// source address is only specified if the socket is unconnected
387
+	if rsa.Addr.Family != AF_UNSPEC {
388
+		from, err = anyToSockaddr(&rsa)
389
+	}
390
+	return
391
+}
392
+
393
+//sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
394
+
395
+func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
396
+	_, err = SendmsgN(fd, p, oob, to, flags)
397
+	return
398
+}
399
+
400
+func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
401
+	var ptr unsafe.Pointer
402
+	var salen _Socklen
403
+	if to != nil {
404
+		ptr, salen, err = to.sockaddr()
405
+		if err != nil {
406
+			return 0, err
407
+		}
408
+	}
409
+	var msg Msghdr
410
+	msg.Name = (*byte)(unsafe.Pointer(ptr))
411
+	msg.Namelen = uint32(salen)
412
+	var iov Iovec
413
+	if len(p) > 0 {
414
+		iov.Base = (*byte)(unsafe.Pointer(&p[0]))
415
+		iov.SetLen(len(p))
416
+	}
417
+	var dummy byte
418
+	if len(oob) > 0 {
419
+		// send at least one normal byte
420
+		if len(p) == 0 {
421
+			iov.Base = &dummy
422
+			iov.SetLen(1)
423
+		}
424
+		msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
425
+		msg.SetControllen(len(oob))
426
+	}
427
+	msg.Iov = &iov
428
+	msg.Iovlen = 1
429
+	if n, err = sendmsg(fd, &msg, flags); err != nil {
430
+		return 0, err
431
+	}
432
+	if len(oob) > 0 && len(p) == 0 {
433
+		n = 0
434
+	}
435
+	return n, nil
436
+}
437
+
438
+//sys	kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error)
439
+
440
+func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) {
441
+	var change, event unsafe.Pointer
442
+	if len(changes) > 0 {
443
+		change = unsafe.Pointer(&changes[0])
444
+	}
445
+	if len(events) > 0 {
446
+		event = unsafe.Pointer(&events[0])
447
+	}
448
+	return kevent(kq, change, len(changes), event, len(events), timeout)
449
+}
450
+
451
+//sys	sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
452
+
453
+// sysctlmib translates name to mib number and appends any additional args.
454
+func sysctlmib(name string, args ...int) ([]_C_int, error) {
455
+	// Translate name to mib number.
456
+	mib, err := nametomib(name)
457
+	if err != nil {
458
+		return nil, err
459
+	}
460
+
461
+	for _, a := range args {
462
+		mib = append(mib, _C_int(a))
463
+	}
464
+
465
+	return mib, nil
466
+}
467
+
468
+func Sysctl(name string) (string, error) {
469
+	return SysctlArgs(name)
470
+}
471
+
472
+func SysctlArgs(name string, args ...int) (string, error) {
473
+	buf, err := SysctlRaw(name, args...)
474
+	if err != nil {
475
+		return "", err
476
+	}
477
+	n := len(buf)
478
+
479
+	// Throw away terminating NUL.
480
+	if n > 0 && buf[n-1] == '\x00' {
481
+		n--
482
+	}
483
+	return string(buf[0:n]), nil
484
+}
485
+
486
+func SysctlUint32(name string) (uint32, error) {
487
+	return SysctlUint32Args(name)
488
+}
489
+
490
+func SysctlUint32Args(name string, args ...int) (uint32, error) {
491
+	mib, err := sysctlmib(name, args...)
492
+	if err != nil {
493
+		return 0, err
494
+	}
495
+
496
+	n := uintptr(4)
497
+	buf := make([]byte, 4)
498
+	if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
499
+		return 0, err
500
+	}
501
+	if n != 4 {
502
+		return 0, EIO
503
+	}
504
+	return *(*uint32)(unsafe.Pointer(&buf[0])), nil
505
+}
506
+
507
+func SysctlUint64(name string, args ...int) (uint64, error) {
508
+	mib, err := sysctlmib(name, args...)
509
+	if err != nil {
510
+		return 0, err
511
+	}
512
+
513
+	n := uintptr(8)
514
+	buf := make([]byte, 8)
515
+	if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
516
+		return 0, err
517
+	}
518
+	if n != 8 {
519
+		return 0, EIO
520
+	}
521
+	return *(*uint64)(unsafe.Pointer(&buf[0])), nil
522
+}
523
+
524
+func SysctlRaw(name string, args ...int) ([]byte, error) {
525
+	mib, err := sysctlmib(name, args...)
526
+	if err != nil {
527
+		return nil, err
528
+	}
529
+
530
+	// Find size.
531
+	n := uintptr(0)
532
+	if err := sysctl(mib, nil, &n, nil, 0); err != nil {
533
+		return nil, err
534
+	}
535
+	if n == 0 {
536
+		return nil, nil
537
+	}
538
+
539
+	// Read into buffer of that size.
540
+	buf := make([]byte, n)
541
+	if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
542
+		return nil, err
543
+	}
544
+
545
+	// The actual call may return less than the original reported required
546
+	// size so ensure we deal with that.
547
+	return buf[:n], nil
548
+}
549
+
550
+//sys	utimes(path string, timeval *[2]Timeval) (err error)
551
+
552
+func Utimes(path string, tv []Timeval) error {
553
+	if tv == nil {
554
+		return utimes(path, nil)
555
+	}
556
+	if len(tv) != 2 {
557
+		return EINVAL
558
+	}
559
+	return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
560
+}
561
+
562
+func UtimesNano(path string, ts []Timespec) error {
563
+	if ts == nil {
564
+		err := utimensat(AT_FDCWD, path, nil, 0)
565
+		if err != ENOSYS {
566
+			return err
567
+		}
568
+		return utimes(path, nil)
569
+	}
570
+	if len(ts) != 2 {
571
+		return EINVAL
572
+	}
573
+	// Darwin setattrlist can set nanosecond timestamps
574
+	err := setattrlistTimes(path, ts, 0)
575
+	if err != ENOSYS {
576
+		return err
577
+	}
578
+	err = utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
579
+	if err != ENOSYS {
580
+		return err
581
+	}
582
+	// Not as efficient as it could be because Timespec and
583
+	// Timeval have different types in the different OSes
584
+	tv := [2]Timeval{
585
+		NsecToTimeval(TimespecToNsec(ts[0])),
586
+		NsecToTimeval(TimespecToNsec(ts[1])),
587
+	}
588
+	return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
589
+}
590
+
591
+func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
592
+	if ts == nil {
593
+		return utimensat(dirfd, path, nil, flags)
594
+	}
595
+	if len(ts) != 2 {
596
+		return EINVAL
597
+	}
598
+	err := setattrlistTimes(path, ts, flags)
599
+	if err != ENOSYS {
600
+		return err
601
+	}
602
+	return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
603
+}
604
+
605
+//sys	futimes(fd int, timeval *[2]Timeval) (err error)
606
+
607
+func Futimes(fd int, tv []Timeval) error {
608
+	if tv == nil {
609
+		return futimes(fd, nil)
610
+	}
611
+	if len(tv) != 2 {
612
+		return EINVAL
613
+	}
614
+	return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
615
+}
616
+
617
+//sys	fcntl(fd int, cmd int, arg int) (val int, err error)
618
+
619
+//sys   poll(fds *PollFd, nfds int, timeout int) (n int, err error)
620
+
621
+func Poll(fds []PollFd, timeout int) (n int, err error) {
622
+	if len(fds) == 0 {
623
+		return poll(nil, 0, timeout)
624
+	}
625
+	return poll(&fds[0], len(fds), timeout)
626
+}
627
+
628
+// TODO: wrap
629
+//	Acct(name nil-string) (err error)
630
+//	Gethostuuid(uuid *byte, timeout *Timespec) (err error)
631
+//	Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error)
632
+
633
+var mapper = &mmapper{
634
+	active: make(map[*byte][]byte),
635
+	mmap:   mmap,
636
+	munmap: munmap,
637
+}
638
+
639
+func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
640
+	return mapper.Mmap(fd, offset, length, prot, flags)
641
+}
642
+
643
+func Munmap(b []byte) (err error) {
644
+	return mapper.Munmap(b)
645
+}
646
+
647
+//sys	Madvise(b []byte, behav int) (err error)
648
+//sys	Mlock(b []byte) (err error)
649
+//sys	Mlockall(flags int) (err error)
650
+//sys	Mprotect(b []byte, prot int) (err error)
651
+//sys	Msync(b []byte, flags int) (err error)
652
+//sys	Munlock(b []byte) (err error)
653
+//sys	Munlockall() (err error)

+ 70
- 0
vendor/src/golang.org/x/sys/unix/syscall_bsd_test.go Ver fichero

@@ -0,0 +1,70 @@
1
+// Copyright 2014 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
+// +build darwin dragonfly freebsd openbsd
6
+
7
+package unix_test
8
+
9
+import (
10
+	"os/exec"
11
+	"runtime"
12
+	"testing"
13
+
14
+	"golang.org/x/sys/unix"
15
+)
16
+
17
+const MNT_WAIT = 1
18
+const MNT_NOWAIT = 2
19
+
20
+func TestGetfsstat(t *testing.T) {
21
+	const flags = MNT_NOWAIT // see golang.org/issue/16937
22
+	n, err := unix.Getfsstat(nil, flags)
23
+	if err != nil {
24
+		t.Fatal(err)
25
+	}
26
+
27
+	data := make([]unix.Statfs_t, n)
28
+	n2, err := unix.Getfsstat(data, flags)
29
+	if err != nil {
30
+		t.Fatal(err)
31
+	}
32
+	if n != n2 {
33
+		t.Errorf("Getfsstat(nil) = %d, but subsequent Getfsstat(slice) = %d", n, n2)
34
+	}
35
+	for i, stat := range data {
36
+		if stat == (unix.Statfs_t{}) {
37
+			t.Errorf("index %v is an empty Statfs_t struct", i)
38
+		}
39
+	}
40
+	if t.Failed() {
41
+		for i, stat := range data[:n2] {
42
+			t.Logf("data[%v] = %+v", i, stat)
43
+		}
44
+		mount, err := exec.Command("mount").CombinedOutput()
45
+		if err != nil {
46
+			t.Logf("mount: %v\n%s", err, mount)
47
+		} else {
48
+			t.Logf("mount: %s", mount)
49
+		}
50
+	}
51
+}
52
+
53
+func TestSysctlRaw(t *testing.T) {
54
+	if runtime.GOOS == "openbsd" {
55
+		t.Skip("kern.proc.pid does not exist on OpenBSD")
56
+	}
57
+
58
+	_, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid())
59
+	if err != nil {
60
+		t.Fatal(err)
61
+	}
62
+}
63
+
64
+func TestSysctlUint32(t *testing.T) {
65
+	maxproc, err := unix.SysctlUint32("kern.maxproc")
66
+	if err != nil {
67
+		t.Fatal(err)
68
+	}
69
+	t.Logf("kern.maxproc: %v", maxproc)
70
+}

+ 612
- 0
vendor/src/golang.org/x/sys/unix/syscall_darwin.go Ver fichero

@@ -0,0 +1,612 @@
1
+// Copyright 2009,2010 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
+// Darwin system calls.
6
+// This file is compiled as ordinary Go code,
7
+// but it is also input to mksyscall,
8
+// which parses the //sys lines and generates system call stubs.
9
+// Note that sometimes we use a lowercase //sys name and wrap
10
+// it in our own nicer implementation, either here or in
11
+// syscall_bsd.go or syscall_unix.go.
12
+
13
+package unix
14
+
15
+import (
16
+	errorspkg "errors"
17
+	"syscall"
18
+	"unsafe"
19
+)
20
+
21
+const ImplementsGetwd = true
22
+
23
+func Getwd() (string, error) {
24
+	buf := make([]byte, 2048)
25
+	attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0)
26
+	if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
27
+		wd := string(attrs[0])
28
+		// Sanity check that it's an absolute path and ends
29
+		// in a null byte, which we then strip.
30
+		if wd[0] == '/' && wd[len(wd)-1] == 0 {
31
+			return wd[:len(wd)-1], nil
32
+		}
33
+	}
34
+	// If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
35
+	// slow algorithm.
36
+	return "", ENOTSUP
37
+}
38
+
39
+type SockaddrDatalink struct {
40
+	Len    uint8
41
+	Family uint8
42
+	Index  uint16
43
+	Type   uint8
44
+	Nlen   uint8
45
+	Alen   uint8
46
+	Slen   uint8
47
+	Data   [12]int8
48
+	raw    RawSockaddrDatalink
49
+}
50
+
51
+// Translate "kern.hostname" to []_C_int{0,1,2,3}.
52
+func nametomib(name string) (mib []_C_int, err error) {
53
+	const siz = unsafe.Sizeof(mib[0])
54
+
55
+	// NOTE(rsc): It seems strange to set the buffer to have
56
+	// size CTL_MAXNAME+2 but use only CTL_MAXNAME
57
+	// as the size. I don't know why the +2 is here, but the
58
+	// kernel uses +2 for its own implementation of this function.
59
+	// I am scared that if we don't include the +2 here, the kernel
60
+	// will silently write 2 words farther than we specify
61
+	// and we'll get memory corruption.
62
+	var buf [CTL_MAXNAME + 2]_C_int
63
+	n := uintptr(CTL_MAXNAME) * siz
64
+
65
+	p := (*byte)(unsafe.Pointer(&buf[0]))
66
+	bytes, err := ByteSliceFromString(name)
67
+	if err != nil {
68
+		return nil, err
69
+	}
70
+
71
+	// Magic sysctl: "setting" 0.3 to a string name
72
+	// lets you read back the array of integers form.
73
+	if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
74
+		return nil, err
75
+	}
76
+	return buf[0 : n/siz], nil
77
+}
78
+
79
+func direntIno(buf []byte) (uint64, bool) {
80
+	return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino))
81
+}
82
+
83
+func direntReclen(buf []byte) (uint64, bool) {
84
+	return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
85
+}
86
+
87
+func direntNamlen(buf []byte) (uint64, bool) {
88
+	return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
89
+}
90
+
91
+//sys   ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
92
+func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
93
+func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
94
+
95
+const (
96
+	attrBitMapCount = 5
97
+	attrCmnFullpath = 0x08000000
98
+)
99
+
100
+type attrList struct {
101
+	bitmapCount uint16
102
+	_           uint16
103
+	CommonAttr  uint32
104
+	VolAttr     uint32
105
+	DirAttr     uint32
106
+	FileAttr    uint32
107
+	Forkattr    uint32
108
+}
109
+
110
+func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
111
+	if len(attrBuf) < 4 {
112
+		return nil, errorspkg.New("attrBuf too small")
113
+	}
114
+	attrList.bitmapCount = attrBitMapCount
115
+
116
+	var _p0 *byte
117
+	_p0, err = BytePtrFromString(path)
118
+	if err != nil {
119
+		return nil, err
120
+	}
121
+
122
+	_, _, e1 := Syscall6(
123
+		SYS_GETATTRLIST,
124
+		uintptr(unsafe.Pointer(_p0)),
125
+		uintptr(unsafe.Pointer(&attrList)),
126
+		uintptr(unsafe.Pointer(&attrBuf[0])),
127
+		uintptr(len(attrBuf)),
128
+		uintptr(options),
129
+		0,
130
+	)
131
+	if e1 != 0 {
132
+		return nil, e1
133
+	}
134
+	size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
135
+
136
+	// dat is the section of attrBuf that contains valid data,
137
+	// without the 4 byte length header. All attribute offsets
138
+	// are relative to dat.
139
+	dat := attrBuf
140
+	if int(size) < len(attrBuf) {
141
+		dat = dat[:size]
142
+	}
143
+	dat = dat[4:] // remove length prefix
144
+
145
+	for i := uint32(0); int(i) < len(dat); {
146
+		header := dat[i:]
147
+		if len(header) < 8 {
148
+			return attrs, errorspkg.New("truncated attribute header")
149
+		}
150
+		datOff := *(*int32)(unsafe.Pointer(&header[0]))
151
+		attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
152
+		if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
153
+			return attrs, errorspkg.New("truncated results; attrBuf too small")
154
+		}
155
+		end := uint32(datOff) + attrLen
156
+		attrs = append(attrs, dat[datOff:end])
157
+		i = end
158
+		if r := i % 4; r != 0 {
159
+			i += (4 - r)
160
+		}
161
+	}
162
+	return
163
+}
164
+
165
+//sysnb pipe() (r int, w int, err error)
166
+
167
+func Pipe(p []int) (err error) {
168
+	if len(p) != 2 {
169
+		return EINVAL
170
+	}
171
+	p[0], p[1], err = pipe()
172
+	return
173
+}
174
+
175
+func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
176
+	var _p0 unsafe.Pointer
177
+	var bufsize uintptr
178
+	if len(buf) > 0 {
179
+		_p0 = unsafe.Pointer(&buf[0])
180
+		bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
181
+	}
182
+	r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, uintptr(flags))
183
+	n = int(r0)
184
+	if e1 != 0 {
185
+		err = e1
186
+	}
187
+	return
188
+}
189
+
190
+func setattrlistTimes(path string, times []Timespec, flags int) error {
191
+	_p0, err := BytePtrFromString(path)
192
+	if err != nil {
193
+		return err
194
+	}
195
+
196
+	var attrList attrList
197
+	attrList.bitmapCount = ATTR_BIT_MAP_COUNT
198
+	attrList.CommonAttr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME
199
+
200
+	// order is mtime, atime: the opposite of Chtimes
201
+	attributes := [2]Timespec{times[1], times[0]}
202
+	options := 0
203
+	if flags&AT_SYMLINK_NOFOLLOW != 0 {
204
+		options |= FSOPT_NOFOLLOW
205
+	}
206
+	_, _, e1 := Syscall6(
207
+		SYS_SETATTRLIST,
208
+		uintptr(unsafe.Pointer(_p0)),
209
+		uintptr(unsafe.Pointer(&attrList)),
210
+		uintptr(unsafe.Pointer(&attributes)),
211
+		uintptr(unsafe.Sizeof(attributes)),
212
+		uintptr(options),
213
+		0,
214
+	)
215
+	if e1 != 0 {
216
+		return e1
217
+	}
218
+	return nil
219
+}
220
+
221
+func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error {
222
+	// Darwin doesn't support SYS_UTIMENSAT
223
+	return ENOSYS
224
+}
225
+
226
+/*
227
+ * Wrapped
228
+ */
229
+
230
+//sys	kill(pid int, signum int, posix int) (err error)
231
+
232
+func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
233
+
234
+//sys	ioctl(fd int, req uint, arg uintptr) (err error)
235
+
236
+// ioctl itself should not be exposed directly, but additional get/set
237
+// functions for specific types are permissible.
238
+
239
+// IoctlSetInt performs an ioctl operation which sets an integer value
240
+// on fd, using the specified request number.
241
+func IoctlSetInt(fd int, req uint, value int) error {
242
+	return ioctl(fd, req, uintptr(value))
243
+}
244
+
245
+func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
246
+	return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
247
+}
248
+
249
+func IoctlSetTermios(fd int, req uint, value *Termios) error {
250
+	return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
251
+}
252
+
253
+// IoctlGetInt performs an ioctl operation which gets an integer value
254
+// from fd, using the specified request number.
255
+func IoctlGetInt(fd int, req uint) (int, error) {
256
+	var value int
257
+	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
258
+	return value, err
259
+}
260
+
261
+func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
262
+	var value Winsize
263
+	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
264
+	return &value, err
265
+}
266
+
267
+func IoctlGetTermios(fd int, req uint) (*Termios, error) {
268
+	var value Termios
269
+	err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
270
+	return &value, err
271
+}
272
+
273
+func Uname(uname *Utsname) error {
274
+	mib := []_C_int{CTL_KERN, KERN_OSTYPE}
275
+	n := unsafe.Sizeof(uname.Sysname)
276
+	if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
277
+		return err
278
+	}
279
+
280
+	mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
281
+	n = unsafe.Sizeof(uname.Nodename)
282
+	if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
283
+		return err
284
+	}
285
+
286
+	mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
287
+	n = unsafe.Sizeof(uname.Release)
288
+	if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
289
+		return err
290
+	}
291
+
292
+	mib = []_C_int{CTL_KERN, KERN_VERSION}
293
+	n = unsafe.Sizeof(uname.Version)
294
+	if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
295
+		return err
296
+	}
297
+
298
+	// The version might have newlines or tabs in it, convert them to
299
+	// spaces.
300
+	for i, b := range uname.Version {
301
+		if b == '\n' || b == '\t' {
302
+			if i == len(uname.Version)-1 {
303
+				uname.Version[i] = 0
304
+			} else {
305
+				uname.Version[i] = ' '
306
+			}
307
+		}
308
+	}
309
+
310
+	mib = []_C_int{CTL_HW, HW_MACHINE}
311
+	n = unsafe.Sizeof(uname.Machine)
312
+	if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
313
+		return err
314
+	}
315
+
316
+	return nil
317
+}
318
+
319
+/*
320
+ * Exposed directly
321
+ */
322
+//sys	Access(path string, mode uint32) (err error)
323
+//sys	Adjtime(delta *Timeval, olddelta *Timeval) (err error)
324
+//sys	Chdir(path string) (err error)
325
+//sys	Chflags(path string, flags int) (err error)
326
+//sys	Chmod(path string, mode uint32) (err error)
327
+//sys	Chown(path string, uid int, gid int) (err error)
328
+//sys	Chroot(path string) (err error)
329
+//sys	Close(fd int) (err error)
330
+//sys	Dup(fd int) (nfd int, err error)
331
+//sys	Dup2(from int, to int) (err error)
332
+//sys	Exchangedata(path1 string, path2 string, options int) (err error)
333
+//sys	Exit(code int)
334
+//sys	Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
335
+//sys	Fchdir(fd int) (err error)
336
+//sys	Fchflags(fd int, flags int) (err error)
337
+//sys	Fchmod(fd int, mode uint32) (err error)
338
+//sys	Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
339
+//sys	Fchown(fd int, uid int, gid int) (err error)
340
+//sys	Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
341
+//sys	Flock(fd int, how int) (err error)
342
+//sys	Fpathconf(fd int, name int) (val int, err error)
343
+//sys	Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
344
+//sys	Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
345
+//sys	Fsync(fd int) (err error)
346
+//sys	Ftruncate(fd int, length int64) (err error)
347
+//sys	Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
348
+//sys	Getdtablesize() (size int)
349
+//sysnb	Getegid() (egid int)
350
+//sysnb	Geteuid() (uid int)
351
+//sysnb	Getgid() (gid int)
352
+//sysnb	Getpgid(pid int) (pgid int, err error)
353
+//sysnb	Getpgrp() (pgrp int)
354
+//sysnb	Getpid() (pid int)
355
+//sysnb	Getppid() (ppid int)
356
+//sys	Getpriority(which int, who int) (prio int, err error)
357
+//sysnb	Getrlimit(which int, lim *Rlimit) (err error)
358
+//sysnb	Getrusage(who int, rusage *Rusage) (err error)
359
+//sysnb	Getsid(pid int) (sid int, err error)
360
+//sysnb	Getuid() (uid int)
361
+//sysnb	Issetugid() (tainted bool)
362
+//sys	Kqueue() (fd int, err error)
363
+//sys	Lchown(path string, uid int, gid int) (err error)
364
+//sys	Link(path string, link string) (err error)
365
+//sys	Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
366
+//sys	Listen(s int, backlog int) (err error)
367
+//sys	Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
368
+//sys	Mkdir(path string, mode uint32) (err error)
369
+//sys	Mkdirat(dirfd int, path string, mode uint32) (err error)
370
+//sys	Mkfifo(path string, mode uint32) (err error)
371
+//sys	Mknod(path string, mode uint32, dev int) (err error)
372
+//sys	Open(path string, mode int, perm uint32) (fd int, err error)
373
+//sys	Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
374
+//sys	Pathconf(path string, name int) (val int, err error)
375
+//sys	Pread(fd int, p []byte, offset int64) (n int, err error)
376
+//sys	Pwrite(fd int, p []byte, offset int64) (n int, err error)
377
+//sys	read(fd int, p []byte) (n int, err error)
378
+//sys	Readlink(path string, buf []byte) (n int, err error)
379
+//sys	Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
380
+//sys	Rename(from string, to string) (err error)
381
+//sys	Renameat(fromfd int, from string, tofd int, to string) (err error)
382
+//sys	Revoke(path string) (err error)
383
+//sys	Rmdir(path string) (err error)
384
+//sys	Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
385
+//sys	Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
386
+//sys	Setegid(egid int) (err error)
387
+//sysnb	Seteuid(euid int) (err error)
388
+//sysnb	Setgid(gid int) (err error)
389
+//sys	Setlogin(name string) (err error)
390
+//sysnb	Setpgid(pid int, pgid int) (err error)
391
+//sys	Setpriority(which int, who int, prio int) (err error)
392
+//sys	Setprivexec(flag int) (err error)
393
+//sysnb	Setregid(rgid int, egid int) (err error)
394
+//sysnb	Setreuid(ruid int, euid int) (err error)
395
+//sysnb	Setrlimit(which int, lim *Rlimit) (err error)
396
+//sysnb	Setsid() (pid int, err error)
397
+//sysnb	Settimeofday(tp *Timeval) (err error)
398
+//sysnb	Setuid(uid int) (err error)
399
+//sys	Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
400
+//sys	Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
401
+//sys	Symlink(path string, link string) (err error)
402
+//sys	Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
403
+//sys	Sync() (err error)
404
+//sys	Truncate(path string, length int64) (err error)
405
+//sys	Umask(newmask int) (oldmask int)
406
+//sys	Undelete(path string) (err error)
407
+//sys	Unlink(path string) (err error)
408
+//sys	Unlinkat(dirfd int, path string, flags int) (err error)
409
+//sys	Unmount(path string, flags int) (err error)
410
+//sys	write(fd int, p []byte) (n int, err error)
411
+//sys   mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
412
+//sys   munmap(addr uintptr, length uintptr) (err error)
413
+//sys	readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
414
+//sys	writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
415
+
416
+/*
417
+ * Unimplemented
418
+ */
419
+// Profil
420
+// Sigaction
421
+// Sigprocmask
422
+// Getlogin
423
+// Sigpending
424
+// Sigaltstack
425
+// Ioctl
426
+// Reboot
427
+// Execve
428
+// Vfork
429
+// Sbrk
430
+// Sstk
431
+// Ovadvise
432
+// Mincore
433
+// Setitimer
434
+// Swapon
435
+// Select
436
+// Sigsuspend
437
+// Readv
438
+// Writev
439
+// Nfssvc
440
+// Getfh
441
+// Quotactl
442
+// Mount
443
+// Csops
444
+// Waitid
445
+// Add_profil
446
+// Kdebug_trace
447
+// Sigreturn
448
+// Atsocket
449
+// Kqueue_from_portset_np
450
+// Kqueue_portset
451
+// Getattrlist
452
+// Setattrlist
453
+// Getdirentriesattr
454
+// Searchfs
455
+// Delete
456
+// Copyfile
457
+// Watchevent
458
+// Waitevent
459
+// Modwatch
460
+// Getxattr
461
+// Fgetxattr
462
+// Setxattr
463
+// Fsetxattr
464
+// Removexattr
465
+// Fremovexattr
466
+// Listxattr
467
+// Flistxattr
468
+// Fsctl
469
+// Initgroups
470
+// Posix_spawn
471
+// Nfsclnt
472
+// Fhopen
473
+// Minherit
474
+// Semsys
475
+// Msgsys
476
+// Shmsys
477
+// Semctl
478
+// Semget
479
+// Semop
480
+// Msgctl
481
+// Msgget
482
+// Msgsnd
483
+// Msgrcv
484
+// Shmat
485
+// Shmctl
486
+// Shmdt
487
+// Shmget
488
+// Shm_open
489
+// Shm_unlink
490
+// Sem_open
491
+// Sem_close
492
+// Sem_unlink
493
+// Sem_wait
494
+// Sem_trywait
495
+// Sem_post
496
+// Sem_getvalue
497
+// Sem_init
498
+// Sem_destroy
499
+// Open_extended
500
+// Umask_extended
501
+// Stat_extended
502
+// Lstat_extended
503
+// Fstat_extended
504
+// Chmod_extended
505
+// Fchmod_extended
506
+// Access_extended
507
+// Settid
508
+// Gettid
509
+// Setsgroups
510
+// Getsgroups
511
+// Setwgroups
512
+// Getwgroups
513
+// Mkfifo_extended
514
+// Mkdir_extended
515
+// Identitysvc
516
+// Shared_region_check_np
517
+// Shared_region_map_np
518
+// __pthread_mutex_destroy
519
+// __pthread_mutex_init
520
+// __pthread_mutex_lock
521
+// __pthread_mutex_trylock
522
+// __pthread_mutex_unlock
523
+// __pthread_cond_init
524
+// __pthread_cond_destroy
525
+// __pthread_cond_broadcast
526
+// __pthread_cond_signal
527
+// Setsid_with_pid
528
+// __pthread_cond_timedwait
529
+// Aio_fsync
530
+// Aio_return
531
+// Aio_suspend
532
+// Aio_cancel
533
+// Aio_error
534
+// Aio_read
535
+// Aio_write
536
+// Lio_listio
537
+// __pthread_cond_wait
538
+// Iopolicysys
539
+// __pthread_kill
540
+// __pthread_sigmask
541
+// __sigwait
542
+// __disable_threadsignal
543
+// __pthread_markcancel
544
+// __pthread_canceled
545
+// __semwait_signal
546
+// Proc_info
547
+// sendfile
548
+// Stat64_extended
549
+// Lstat64_extended
550
+// Fstat64_extended
551
+// __pthread_chdir
552
+// __pthread_fchdir
553
+// Audit
554
+// Auditon
555
+// Getauid
556
+// Setauid
557
+// Getaudit
558
+// Setaudit
559
+// Getaudit_addr
560
+// Setaudit_addr
561
+// Auditctl
562
+// Bsdthread_create
563
+// Bsdthread_terminate
564
+// Stack_snapshot
565
+// Bsdthread_register
566
+// Workq_open
567
+// Workq_ops
568
+// __mac_execve
569
+// __mac_syscall
570
+// __mac_get_file
571
+// __mac_set_file
572
+// __mac_get_link
573
+// __mac_set_link
574
+// __mac_get_proc
575
+// __mac_set_proc
576
+// __mac_get_fd
577
+// __mac_set_fd
578
+// __mac_get_pid
579
+// __mac_get_lcid
580
+// __mac_get_lctx
581
+// __mac_set_lctx
582
+// Setlcid
583
+// Read_nocancel
584
+// Write_nocancel
585
+// Open_nocancel
586
+// Close_nocancel
587
+// Wait4_nocancel
588
+// Recvmsg_nocancel
589
+// Sendmsg_nocancel
590
+// Recvfrom_nocancel
591
+// Accept_nocancel
592
+// Fcntl_nocancel
593
+// Select_nocancel
594
+// Fsync_nocancel
595
+// Connect_nocancel
596
+// Sigsuspend_nocancel
597
+// Readv_nocancel
598
+// Writev_nocancel
599
+// Sendto_nocancel
600
+// Pread_nocancel
601
+// Pwrite_nocancel
602
+// Waitid_nocancel
603
+// Poll_nocancel
604
+// Msgsnd_nocancel
605
+// Msgrcv_nocancel
606
+// Sem_wait_nocancel
607
+// Aio_suspend_nocancel
608
+// __sigwait_nocancel
609
+// __semwait_signal_nocancel
610
+// __mac_mount
611
+// __mac_get_mount
612
+// __mac_getfsstat

+ 68
- 0
vendor/src/golang.org/x/sys/unix/syscall_darwin_386.go Ver fichero

@@ -0,0 +1,68 @@
1
+// Copyright 2009 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
+// +build 386,darwin
6
+
7
+package unix
8
+
9
+import (
10
+	"syscall"
11
+	"unsafe"
12
+)
13
+
14
+func setTimespec(sec, nsec int64) Timespec {
15
+	return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
16
+}
17
+
18
+func setTimeval(sec, usec int64) Timeval {
19
+	return Timeval{Sec: int32(sec), Usec: int32(usec)}
20
+}
21
+
22
+//sysnb	gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
23
+func Gettimeofday(tv *Timeval) (err error) {
24
+	// The tv passed to gettimeofday must be non-nil
25
+	// but is otherwise unused. The answers come back
26
+	// in the two registers.
27
+	sec, usec, err := gettimeofday(tv)
28
+	tv.Sec = int32(sec)
29
+	tv.Usec = int32(usec)
30
+	return err
31
+}
32
+
33
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
34
+	k.Ident = uint32(fd)
35
+	k.Filter = int16(mode)
36
+	k.Flags = uint16(flags)
37
+}
38
+
39
+func (iov *Iovec) SetLen(length int) {
40
+	iov.Len = uint32(length)
41
+}
42
+
43
+func (msghdr *Msghdr) SetControllen(length int) {
44
+	msghdr.Controllen = uint32(length)
45
+}
46
+
47
+func (cmsg *Cmsghdr) SetLen(length int) {
48
+	cmsg.Len = uint32(length)
49
+}
50
+
51
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
52
+	var length = uint64(count)
53
+
54
+	_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
55
+
56
+	written = int(length)
57
+
58
+	if e1 != 0 {
59
+		err = e1
60
+	}
61
+	return
62
+}
63
+
64
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
65
+
66
+// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
67
+// of darwin/386 the syscall is called sysctl instead of __sysctl.
68
+const SYS___SYSCTL = SYS_SYSCTL

+ 68
- 0
vendor/src/golang.org/x/sys/unix/syscall_darwin_amd64.go Ver fichero

@@ -0,0 +1,68 @@
1
+// Copyright 2009 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
+// +build amd64,darwin
6
+
7
+package unix
8
+
9
+import (
10
+	"syscall"
11
+	"unsafe"
12
+)
13
+
14
+func setTimespec(sec, nsec int64) Timespec {
15
+	return Timespec{Sec: sec, Nsec: nsec}
16
+}
17
+
18
+func setTimeval(sec, usec int64) Timeval {
19
+	return Timeval{Sec: sec, Usec: int32(usec)}
20
+}
21
+
22
+//sysnb	gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
23
+func Gettimeofday(tv *Timeval) (err error) {
24
+	// The tv passed to gettimeofday must be non-nil
25
+	// but is otherwise unused. The answers come back
26
+	// in the two registers.
27
+	sec, usec, err := gettimeofday(tv)
28
+	tv.Sec = sec
29
+	tv.Usec = usec
30
+	return err
31
+}
32
+
33
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
34
+	k.Ident = uint64(fd)
35
+	k.Filter = int16(mode)
36
+	k.Flags = uint16(flags)
37
+}
38
+
39
+func (iov *Iovec) SetLen(length int) {
40
+	iov.Len = uint64(length)
41
+}
42
+
43
+func (msghdr *Msghdr) SetControllen(length int) {
44
+	msghdr.Controllen = uint32(length)
45
+}
46
+
47
+func (cmsg *Cmsghdr) SetLen(length int) {
48
+	cmsg.Len = uint32(length)
49
+}
50
+
51
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
52
+	var length = uint64(count)
53
+
54
+	_, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
55
+
56
+	written = int(length)
57
+
58
+	if e1 != 0 {
59
+		err = e1
60
+	}
61
+	return
62
+}
63
+
64
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
65
+
66
+// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
67
+// of darwin/amd64 the syscall is called sysctl instead of __sysctl.
68
+const SYS___SYSCTL = SYS_SYSCTL

+ 62
- 0
vendor/src/golang.org/x/sys/unix/syscall_darwin_arm.go Ver fichero

@@ -0,0 +1,62 @@
1
+// Copyright 2015 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
+package unix
6
+
7
+import (
8
+	"syscall"
9
+	"unsafe"
10
+)
11
+
12
+func setTimespec(sec, nsec int64) Timespec {
13
+	return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
14
+}
15
+
16
+func setTimeval(sec, usec int64) Timeval {
17
+	return Timeval{Sec: int32(sec), Usec: int32(usec)}
18
+}
19
+
20
+//sysnb	gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
21
+func Gettimeofday(tv *Timeval) (err error) {
22
+	// The tv passed to gettimeofday must be non-nil
23
+	// but is otherwise unused. The answers come back
24
+	// in the two registers.
25
+	sec, usec, err := gettimeofday(tv)
26
+	tv.Sec = int32(sec)
27
+	tv.Usec = int32(usec)
28
+	return err
29
+}
30
+
31
+func SetKevent(k *Kevent_t, fd, mode, flags int) {
32
+	k.Ident = uint32(fd)
33
+	k.Filter = int16(mode)
34
+	k.Flags = uint16(flags)
35
+}
36
+
37
+func (iov *Iovec) SetLen(length int) {
38
+	iov.Len = uint32(length)
39
+}
40
+
41
+func (msghdr *Msghdr) SetControllen(length int) {
42
+	msghdr.Controllen = uint32(length)
43
+}
44
+
45
+func (cmsg *Cmsghdr) SetLen(length int) {
46
+	cmsg.Len = uint32(length)
47
+}
48
+
49
+func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
50
+	var length = uint64(count)
51
+
52
+	_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
53
+
54
+	written = int(length)
55
+
56
+	if e1 != 0 {
57
+		err = e1
58
+	}
59
+	return
60
+}
61
+
62
+func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic

+ 0
- 0
vendor/src/golang.org/x/sys/unix/syscall_darwin_arm64.go Ver fichero


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio