Browse Source

Added Windows Support

Wirecog 6 years ago
parent
commit
fba4bbc277
100 changed files with 8292 additions and 20 deletions
  1. 3
    4
      Readme.md
  2. 1
    16
      kick.go
  3. 26
    0
      startstop_unixlike.go
  4. 23
    0
      startstop_windows.go
  5. 5
    0
      vendor/github.com/fsnotify/fsnotify/.editorconfig
  6. 11
    0
      vendor/github.com/fsnotify/fsnotify/.github/ISSUE_TEMPLATE.md
  7. 8
    0
      vendor/github.com/fsnotify/fsnotify/.github/PULL_REQUEST_TEMPLATE.md
  8. 6
    0
      vendor/github.com/fsnotify/fsnotify/.gitignore
  9. 30
    0
      vendor/github.com/fsnotify/fsnotify/.travis.yml
  10. 46
    0
      vendor/github.com/fsnotify/fsnotify/AUTHORS
  11. 307
    0
      vendor/github.com/fsnotify/fsnotify/CHANGELOG.md
  12. 77
    0
      vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md
  13. 28
    0
      vendor/github.com/fsnotify/fsnotify/LICENSE
  14. 79
    0
      vendor/github.com/fsnotify/fsnotify/README.md
  15. 42
    0
      vendor/github.com/fsnotify/fsnotify/example_test.go
  16. 37
    0
      vendor/github.com/fsnotify/fsnotify/fen.go
  17. 66
    0
      vendor/github.com/fsnotify/fsnotify/fsnotify.go
  18. 40
    0
      vendor/github.com/fsnotify/fsnotify/fsnotify_test.go
  19. 337
    0
      vendor/github.com/fsnotify/fsnotify/inotify.go
  20. 187
    0
      vendor/github.com/fsnotify/fsnotify/inotify_poller.go
  21. 229
    0
      vendor/github.com/fsnotify/fsnotify/inotify_poller_test.go
  22. 449
    0
      vendor/github.com/fsnotify/fsnotify/inotify_test.go
  23. 147
    0
      vendor/github.com/fsnotify/fsnotify/integration_darwin_test.go
  24. 1237
    0
      vendor/github.com/fsnotify/fsnotify/integration_test.go
  25. 503
    0
      vendor/github.com/fsnotify/fsnotify/kqueue.go
  26. 11
    0
      vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go
  27. 12
    0
      vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go
  28. 561
    0
      vendor/github.com/fsnotify/fsnotify/windows.go
  29. 10
    0
      vendor/golang.org/x/sys/.gitattributes
  30. 2
    0
      vendor/golang.org/x/sys/.gitignore
  31. 3
    0
      vendor/golang.org/x/sys/AUTHORS
  32. 31
    0
      vendor/golang.org/x/sys/CONTRIBUTING.md
  33. 3
    0
      vendor/golang.org/x/sys/CONTRIBUTORS
  34. 27
    0
      vendor/golang.org/x/sys/LICENSE
  35. 22
    0
      vendor/golang.org/x/sys/PATENTS
  36. 3
    0
      vendor/golang.org/x/sys/README
  37. 1
    0
      vendor/golang.org/x/sys/codereview.cfg
  38. 8
    0
      vendor/golang.org/x/sys/plan9/asm.s
  39. 30
    0
      vendor/golang.org/x/sys/plan9/asm_plan9_386.s
  40. 30
    0
      vendor/golang.org/x/sys/plan9/asm_plan9_amd64.s
  41. 70
    0
      vendor/golang.org/x/sys/plan9/const_plan9.go
  42. 212
    0
      vendor/golang.org/x/sys/plan9/dir_plan9.go
  43. 27
    0
      vendor/golang.org/x/sys/plan9/env_plan9.go
  44. 14
    0
      vendor/golang.org/x/sys/plan9/env_unset.go
  45. 50
    0
      vendor/golang.org/x/sys/plan9/errors_plan9.go
  46. 138
    0
      vendor/golang.org/x/sys/plan9/mkall.sh
  47. 246
    0
      vendor/golang.org/x/sys/plan9/mkerrors.sh
  48. 319
    0
      vendor/golang.org/x/sys/plan9/mksyscall.pl
  49. 23
    0
      vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh
  50. 21
    0
      vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go
  51. 23
    0
      vendor/golang.org/x/sys/plan9/pwd_plan9.go
  52. 30
    0
      vendor/golang.org/x/sys/plan9/race.go
  53. 25
    0
      vendor/golang.org/x/sys/plan9/race0.go
  54. 22
    0
      vendor/golang.org/x/sys/plan9/str.go
  55. 74
    0
      vendor/golang.org/x/sys/plan9/syscall.go
  56. 349
    0
      vendor/golang.org/x/sys/plan9/syscall_plan9.go
  57. 33
    0
      vendor/golang.org/x/sys/plan9/syscall_test.go
  58. 292
    0
      vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go
  59. 292
    0
      vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go
  60. 49
    0
      vendor/golang.org/x/sys/plan9/zsysnum_plan9.go
  61. 1
    0
      vendor/golang.org/x/sys/unix/.gitignore
  62. 173
    0
      vendor/golang.org/x/sys/unix/README.md
  63. 29
    0
      vendor/golang.org/x/sys/unix/asm_darwin_386.s
  64. 29
    0
      vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
  65. 30
    0
      vendor/golang.org/x/sys/unix/asm_darwin_arm.s
  66. 30
    0
      vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
  67. 29
    0
      vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
  68. 29
    0
      vendor/golang.org/x/sys/unix/asm_freebsd_386.s
  69. 29
    0
      vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
  70. 29
    0
      vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
  71. 35
    0
      vendor/golang.org/x/sys/unix/asm_linux_386.s
  72. 29
    0
      vendor/golang.org/x/sys/unix/asm_linux_amd64.s
  73. 29
    0
      vendor/golang.org/x/sys/unix/asm_linux_arm.s
  74. 24
    0
      vendor/golang.org/x/sys/unix/asm_linux_arm64.s
  75. 28
    0
      vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
  76. 31
    0
      vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
  77. 28
    0
      vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
  78. 28
    0
      vendor/golang.org/x/sys/unix/asm_linux_s390x.s
  79. 29
    0
      vendor/golang.org/x/sys/unix/asm_netbsd_386.s
  80. 29
    0
      vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
  81. 29
    0
      vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
  82. 29
    0
      vendor/golang.org/x/sys/unix/asm_openbsd_386.s
  83. 29
    0
      vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
  84. 17
    0
      vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
  85. 35
    0
      vendor/golang.org/x/sys/unix/bluetooth_linux.go
  86. 13
    0
      vendor/golang.org/x/sys/unix/constants.go
  87. 121
    0
      vendor/golang.org/x/sys/unix/creds_test.go
  88. 102
    0
      vendor/golang.org/x/sys/unix/dirent.go
  89. 9
    0
      vendor/golang.org/x/sys/unix/endian_big.go
  90. 9
    0
      vendor/golang.org/x/sys/unix/endian_little.go
  91. 27
    0
      vendor/golang.org/x/sys/unix/env_unix.go
  92. 14
    0
      vendor/golang.org/x/sys/unix/env_unset.go
  93. 9
    0
      vendor/golang.org/x/sys/unix/export_test.go
  94. 24
    0
      vendor/golang.org/x/sys/unix/flock.go
  95. 13
    0
      vendor/golang.org/x/sys/unix/flock_linux_32bit.go
  96. 46
    0
      vendor/golang.org/x/sys/unix/gccgo.go
  97. 41
    0
      vendor/golang.org/x/sys/unix/gccgo_c.c
  98. 20
    0
      vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
  99. 20
    0
      vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go
  100. 0
    0
      vendor/golang.org/x/sys/unix/linux/Dockerfile

+ 3
- 4
Readme.md View File

@@ -10,13 +10,12 @@ An *instant kickstart* consists of a recompilation of the Go code and a restart
10 10
 
11 11
 Kick comes with the ability to take both the `go` and `gopherjs` commands into consideration when performing the *instant kickstart*.
12 12
 
13
-Please note, that Kick, currently works on Unix-like operating systems (e.g., BSD, Linux, Mac OS) only. 
14
-
15
-Kick doesn't work on Windows, due to some [technical limitations](https://github.com/fsnotify/fsnotify/issues/53).
13
+## Supported Operating Systems
14
+Kick works on Windows and Unix-like operating systems (e.g., BSD, Linux, Mac OS).
16 15
 
17 16
 ## Installation
18 17
 
19
-Before installing Kick, it is recommended, to install the barebones [isogoapp](https://github.com/isomorphicgo/isogoapp) first – since it will provide you an example of how to use kick.
18
+Before installing Kick, it is recommended, to install the barebones [isogoapp](https://github.com/isomorphicgo/isogoapp) first – since it will provide you with an example of how to use kick.
20 19
 
21 20
 ### Get Kick
22 21
 `go get -u github.com/isomorphicgo/kick`

+ 1
- 16
kick.go View File

@@ -13,7 +13,6 @@ import (
13 13
 	"os/exec"
14 14
 	"os/signal"
15 15
 	"path/filepath"
16
-	"syscall"
17 16
 
18 17
 	"github.com/fsnotify/fsnotify"
19 18
 )
@@ -22,7 +21,7 @@ var appPath string
22 21
 var mainSourceFile string
23 22
 var gopherjsAppPath string
24 23
 
25
-func start() *exec.Cmd {
24
+func buildGopherJSProject() {
26 25
 
27 26
 	if gopherjsAppPath != "" {
28 27
 
@@ -39,20 +38,6 @@ func start() *exec.Cmd {
39 38
 		}
40 39
 	}
41 40
 
42
-	cmd := exec.Command("go", "run", appPath+"/"+mainSourceFile)
43
-	cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
44
-	cmd.Stdout = os.Stdout
45
-	cmd.Stderr = os.Stderr
46
-	cmd.Start()
47
-	return cmd
48
-
49
-}
50
-
51
-func stop(cmd *exec.Cmd) {
52
-	pgid, err := syscall.Getpgid(cmd.Process.Pid)
53
-	if err == nil {
54
-		syscall.Kill(-pgid, 15)
55
-	}
56 41
 }
57 42
 
58 43
 func restart(cmd *exec.Cmd) *exec.Cmd {

+ 26
- 0
startstop_unixlike.go View File

@@ -0,0 +1,26 @@
1
+// +build !windows
2
+
3
+package main
4
+
5
+import (
6
+	"os"
7
+	"os/exec"
8
+	"syscall"
9
+)
10
+
11
+func start() *exec.Cmd {
12
+	buildGopherJSProject()
13
+	cmd := exec.Command("go", "run", appPath+"/"+mainSourceFile)
14
+	cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
15
+	cmd.Stdout = os.Stdout
16
+	cmd.Stderr = os.Stderr
17
+	cmd.Start()
18
+	return cmd
19
+}
20
+
21
+func stop(cmd *exec.Cmd) {
22
+	pgid, err := syscall.Getpgid(cmd.Process.Pid)
23
+	if err == nil {
24
+		syscall.Kill(-pgid, 15)
25
+	}
26
+}

+ 23
- 0
startstop_windows.go View File

@@ -0,0 +1,23 @@
1
+// +build windows
2
+
3
+package main
4
+
5
+import (
6
+	"os"
7
+	"os/exec"
8
+	"strconv"
9
+)
10
+
11
+func start() *exec.Cmd {
12
+	buildGopherJSProject()
13
+	cmd := exec.Command("go", "run", appPath+"/"+mainSourceFile)
14
+	cmd.Stdout = os.Stdout
15
+	cmd.Stderr = os.Stderr
16
+	cmd.Start()
17
+	return cmd
18
+}
19
+
20
+func stop(cmd *exec.Cmd) {
21
+	stop := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(cmd.Process.Pid))
22
+	stop.Run()
23
+}

+ 5
- 0
vendor/github.com/fsnotify/fsnotify/.editorconfig View File

@@ -0,0 +1,5 @@
1
+root = true
2
+
3
+[*]
4
+indent_style = tab
5
+indent_size = 4

+ 11
- 0
vendor/github.com/fsnotify/fsnotify/.github/ISSUE_TEMPLATE.md View File

@@ -0,0 +1,11 @@
1
+Before reporting an issue, please ensure you are using the latest release of fsnotify.
2
+
3
+### Which operating system (GOOS) and version are you using?
4
+
5
+Linux: lsb_release -a
6
+macOS: sw_vers
7
+Windows: systeminfo | findstr /B /C:OS
8
+
9
+### Please describe the issue that occurred.
10
+
11
+### Are you able to reproduce the issue? Please provide steps to reproduce and a code sample if possible.

+ 8
- 0
vendor/github.com/fsnotify/fsnotify/.github/PULL_REQUEST_TEMPLATE.md View File

@@ -0,0 +1,8 @@
1
+#### What does this pull request do?
2
+
3
+
4
+#### Where should the reviewer start?
5
+
6
+
7
+#### How should this be manually tested?
8
+

+ 6
- 0
vendor/github.com/fsnotify/fsnotify/.gitignore View File

@@ -0,0 +1,6 @@
1
+# Setup a Global .gitignore for OS and editor generated files:
2
+# https://help.github.com/articles/ignoring-files
3
+# git config --global core.excludesfile ~/.gitignore_global
4
+
5
+.vagrant
6
+*.sublime-project

+ 30
- 0
vendor/github.com/fsnotify/fsnotify/.travis.yml View File

@@ -0,0 +1,30 @@
1
+sudo: false
2
+language: go
3
+
4
+go:
5
+  - 1.8
6
+  - 1.7.x
7
+  - tip
8
+
9
+matrix:
10
+  allow_failures:
11
+    - go: tip
12
+  fast_finish: true
13
+
14
+before_script:
15
+  - go get -u github.com/golang/lint/golint
16
+
17
+script:
18
+  - go test -v --race ./...
19
+
20
+after_script:
21
+  - test -z "$(gofmt -s -l -w . | tee /dev/stderr)"
22
+  - test -z "$(golint ./...     | tee /dev/stderr)"
23
+  - go vet ./...
24
+
25
+os:
26
+  - linux
27
+  - osx
28
+
29
+notifications:
30
+  email: false

+ 46
- 0
vendor/github.com/fsnotify/fsnotify/AUTHORS View File

@@ -0,0 +1,46 @@
1
+# Names should be added to this file as
2
+#	Name or Organization <email address>
3
+# The email address is not required for organizations.
4
+
5
+# You can update this list using the following command:
6
+#
7
+#   $ git shortlog -se | awk '{print $2 " " $3 " " $4}'
8
+
9
+# Please keep the list sorted.
10
+
11
+Adrien Bustany <adrien@bustany.org>
12
+Amit Krishnan <amit.krishnan@oracle.com>
13
+Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
14
+Bruno Bigras <bigras.bruno@gmail.com>
15
+Caleb Spare <cespare@gmail.com>
16
+Case Nelson <case@teammating.com>
17
+Chris Howey <chris@howey.me> <howeyc@gmail.com>
18
+Christoffer Buchholz <christoffer.buchholz@gmail.com>
19
+Daniel Wagner-Hall <dawagner@gmail.com>
20
+Dave Cheney <dave@cheney.net>
21
+Evan Phoenix <evan@fallingsnow.net>
22
+Francisco Souza <f@souza.cc>
23
+Hari haran <hariharan.uno@gmail.com>
24
+John C Barstow
25
+Kelvin Fo <vmirage@gmail.com>
26
+Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>
27
+Matt Layher <mdlayher@gmail.com>
28
+Nathan Youngman <git@nathany.com>
29
+Patrick <patrick@dropbox.com>
30
+Paul Hammond <paul@paulhammond.org>
31
+Pawel Knap <pawelknap88@gmail.com>
32
+Pieter Droogendijk <pieter@binky.org.uk>
33
+Pursuit92 <JoshChase@techpursuit.net>
34
+Riku Voipio <riku.voipio@linaro.org>
35
+Rob Figueiredo <robfig@gmail.com>
36
+Slawek Ligus <root@ooz.ie>
37
+Soge Zhang <zhssoge@gmail.com>
38
+Tiffany Jernigan <tiffany.jernigan@intel.com>
39
+Tilak Sharma <tilaks@google.com>
40
+Travis Cline <travis.cline@gmail.com>
41
+Tudor Golubenco <tudor.g@gmail.com>
42
+Yukang <moorekang@gmail.com>
43
+bronze1man <bronze1man@gmail.com>
44
+debrando <denis.brandolini@gmail.com>
45
+henrikedwards <henrik.edwards@gmail.com>
46
+铁哥 <guotie.9@gmail.com>

+ 307
- 0
vendor/github.com/fsnotify/fsnotify/CHANGELOG.md View File

@@ -0,0 +1,307 @@
1
+# Changelog
2
+
3
+## v1.4.2 / 2016-10-10
4
+
5
+* Linux: use InotifyInit1 with IN_CLOEXEC to stop leaking a file descriptor to a child process when using fork/exec [#178](https://github.com/fsnotify/fsnotify/pull/178) (thanks @pattyshack)
6
+
7
+## v1.4.1 / 2016-10-04
8
+
9
+* Fix flaky inotify stress test on Linux [#177](https://github.com/fsnotify/fsnotify/pull/177) (thanks @pattyshack)
10
+
11
+## v1.4.0 / 2016-10-01
12
+
13
+* add a String() method to Event.Op [#165](https://github.com/fsnotify/fsnotify/pull/165) (thanks @oozie)
14
+
15
+## v1.3.1 / 2016-06-28
16
+
17
+* Windows: fix for double backslash when watching the root of a drive [#151](https://github.com/fsnotify/fsnotify/issues/151) (thanks @brunoqc)
18
+
19
+## v1.3.0 / 2016-04-19
20
+
21
+* Support linux/arm64 by [patching](https://go-review.googlesource.com/#/c/21971/) x/sys/unix and switching to to it from syscall (thanks @suihkulokki) [#135](https://github.com/fsnotify/fsnotify/pull/135)
22
+
23
+## v1.2.10 / 2016-03-02
24
+
25
+* Fix golint errors in windows.go [#121](https://github.com/fsnotify/fsnotify/pull/121) (thanks @tiffanyfj)
26
+
27
+## v1.2.9 / 2016-01-13
28
+
29
+kqueue: Fix logic for CREATE after REMOVE [#111](https://github.com/fsnotify/fsnotify/pull/111) (thanks @bep)
30
+
31
+## v1.2.8 / 2015-12-17
32
+
33
+* kqueue: fix race condition in Close [#105](https://github.com/fsnotify/fsnotify/pull/105) (thanks @djui for reporting the issue and @ppknap for writing a failing test)
34
+* inotify: fix race in test
35
+* enable race detection for continuous integration (Linux, Mac, Windows)
36
+
37
+## v1.2.5 / 2015-10-17
38
+
39
+* inotify: use epoll_create1 for arm64 support (requires Linux 2.6.27 or later) [#100](https://github.com/fsnotify/fsnotify/pull/100) (thanks @suihkulokki)
40
+* inotify: fix path leaks [#73](https://github.com/fsnotify/fsnotify/pull/73) (thanks @chamaken)
41
+* kqueue: watch for rename events on subdirectories [#83](https://github.com/fsnotify/fsnotify/pull/83) (thanks @guotie)
42
+* kqueue: avoid infinite loops from symlinks cycles [#101](https://github.com/fsnotify/fsnotify/pull/101) (thanks @illicitonion)
43
+
44
+## v1.2.1 / 2015-10-14
45
+
46
+* kqueue: don't watch named pipes [#98](https://github.com/fsnotify/fsnotify/pull/98) (thanks @evanphx)
47
+
48
+## v1.2.0 / 2015-02-08
49
+
50
+* inotify: use epoll to wake up readEvents [#66](https://github.com/fsnotify/fsnotify/pull/66) (thanks @PieterD)
51
+* inotify: closing watcher should now always shut down goroutine [#63](https://github.com/fsnotify/fsnotify/pull/63) (thanks @PieterD)
52
+* kqueue: close kqueue after removing watches, fixes [#59](https://github.com/fsnotify/fsnotify/issues/59)
53
+
54
+## v1.1.1 / 2015-02-05
55
+
56
+* inotify: Retry read on EINTR [#61](https://github.com/fsnotify/fsnotify/issues/61) (thanks @PieterD)
57
+
58
+## v1.1.0 / 2014-12-12
59
+
60
+* kqueue: rework internals [#43](https://github.com/fsnotify/fsnotify/pull/43)
61
+    * add low-level functions
62
+    * only need to store flags on directories
63
+    * less mutexes [#13](https://github.com/fsnotify/fsnotify/issues/13)
64
+    * done can be an unbuffered channel
65
+    * remove calls to os.NewSyscallError
66
+* More efficient string concatenation for Event.String() [#52](https://github.com/fsnotify/fsnotify/pull/52) (thanks @mdlayher)
67
+* kqueue: fix regression in  rework causing subdirectories to be watched [#48](https://github.com/fsnotify/fsnotify/issues/48)
68
+* kqueue: cleanup internal watch before sending remove event [#51](https://github.com/fsnotify/fsnotify/issues/51)
69
+
70
+## v1.0.4 / 2014-09-07
71
+
72
+* kqueue: add dragonfly to the build tags.
73
+* Rename source code files, rearrange code so exported APIs are at the top.
74
+* Add done channel to example code. [#37](https://github.com/fsnotify/fsnotify/pull/37) (thanks @chenyukang)
75
+
76
+## v1.0.3 / 2014-08-19
77
+
78
+* [Fix] Windows MOVED_TO now translates to Create like on BSD and Linux. [#36](https://github.com/fsnotify/fsnotify/issues/36)
79
+
80
+## v1.0.2 / 2014-08-17
81
+
82
+* [Fix] Missing create events on macOS. [#14](https://github.com/fsnotify/fsnotify/issues/14) (thanks @zhsso)
83
+* [Fix] Make ./path and path equivalent. (thanks @zhsso)
84
+
85
+## v1.0.0 / 2014-08-15
86
+
87
+* [API] Remove AddWatch on Windows, use Add.
88
+* Improve documentation for exported identifiers. [#30](https://github.com/fsnotify/fsnotify/issues/30)
89
+* Minor updates based on feedback from golint.
90
+
91
+## dev / 2014-07-09
92
+
93
+* Moved to [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify).
94
+* Use os.NewSyscallError instead of returning errno (thanks @hariharan-uno)
95
+
96
+## dev / 2014-07-04
97
+
98
+* kqueue: fix incorrect mutex used in Close()
99
+* Update example to demonstrate usage of Op.
100
+
101
+## dev / 2014-06-28
102
+
103
+* [API] Don't set the Write Op for attribute notifications [#4](https://github.com/fsnotify/fsnotify/issues/4)
104
+* Fix for String() method on Event (thanks Alex Brainman)
105
+* Don't build on Plan 9 or Solaris (thanks @4ad)
106
+
107
+## dev / 2014-06-21
108
+
109
+* Events channel of type Event rather than *Event.
110
+* [internal] use syscall constants directly for inotify and kqueue.
111
+* [internal] kqueue: rename events to kevents and fileEvent to event.
112
+
113
+## dev / 2014-06-19
114
+
115
+* Go 1.3+ required on Windows (uses syscall.ERROR_MORE_DATA internally).
116
+* [internal] remove cookie from Event struct (unused).
117
+* [internal] Event struct has the same definition across every OS.
118
+* [internal] remove internal watch and removeWatch methods.
119
+
120
+## dev / 2014-06-12
121
+
122
+* [API] Renamed Watch() to Add() and RemoveWatch() to Remove().
123
+* [API] Pluralized channel names: Events and Errors.
124
+* [API] Renamed FileEvent struct to Event.
125
+* [API] Op constants replace methods like IsCreate().
126
+
127
+## dev / 2014-06-12
128
+
129
+* Fix data race on kevent buffer (thanks @tilaks) [#98](https://github.com/howeyc/fsnotify/pull/98)
130
+
131
+## dev / 2014-05-23
132
+
133
+* [API] Remove current implementation of WatchFlags.
134
+    * current implementation doesn't take advantage of OS for efficiency
135
+    * provides little benefit over filtering events as they are received, but has  extra bookkeeping and mutexes
136
+    * no tests for the current implementation
137
+    * not fully implemented on Windows [#93](https://github.com/howeyc/fsnotify/issues/93#issuecomment-39285195)
138
+
139
+## v0.9.3 / 2014-12-31
140
+
141
+* kqueue: cleanup internal watch before sending remove event [#51](https://github.com/fsnotify/fsnotify/issues/51)
142
+
143
+## v0.9.2 / 2014-08-17
144
+
145
+* [Backport] Fix missing create events on macOS. [#14](https://github.com/fsnotify/fsnotify/issues/14) (thanks @zhsso)
146
+
147
+## v0.9.1 / 2014-06-12
148
+
149
+* Fix data race on kevent buffer (thanks @tilaks) [#98](https://github.com/howeyc/fsnotify/pull/98)
150
+
151
+## v0.9.0 / 2014-01-17
152
+
153
+* IsAttrib() for events that only concern a file's metadata [#79][] (thanks @abustany)
154
+* [Fix] kqueue: fix deadlock [#77][] (thanks @cespare)
155
+* [NOTICE] Development has moved to `code.google.com/p/go.exp/fsnotify` in preparation for inclusion in the Go standard library.
156
+
157
+## v0.8.12 / 2013-11-13
158
+
159
+* [API] Remove FD_SET and friends from Linux adapter
160
+
161
+## v0.8.11 / 2013-11-02
162
+
163
+* [Doc] Add Changelog [#72][] (thanks @nathany)
164
+* [Doc] Spotlight and double modify events on macOS [#62][] (reported by @paulhammond)
165
+
166
+## v0.8.10 / 2013-10-19
167
+
168
+* [Fix] kqueue: remove file watches when parent directory is removed [#71][] (reported by @mdwhatcott)
169
+* [Fix] kqueue: race between Close and readEvents [#70][] (reported by @bernerdschaefer)
170
+* [Doc] specify OS-specific limits in README (thanks @debrando)
171
+
172
+## v0.8.9 / 2013-09-08
173
+
174
+* [Doc] Contributing (thanks @nathany)
175
+* [Doc] update package path in example code [#63][] (thanks @paulhammond)
176
+* [Doc] GoCI badge in README (Linux only) [#60][]
177
+* [Doc] Cross-platform testing with Vagrant  [#59][] (thanks @nathany)
178
+
179
+## v0.8.8 / 2013-06-17
180
+
181
+* [Fix] Windows: handle `ERROR_MORE_DATA` on Windows [#49][] (thanks @jbowtie)
182
+
183
+## v0.8.7 / 2013-06-03
184
+
185
+* [API] Make syscall flags internal
186
+* [Fix] inotify: ignore event changes
187
+* [Fix] race in symlink test [#45][] (reported by @srid)
188
+* [Fix] tests on Windows
189
+* lower case error messages
190
+
191
+## v0.8.6 / 2013-05-23
192
+
193
+* kqueue: Use EVT_ONLY flag on Darwin
194
+* [Doc] Update README with full example
195
+
196
+## v0.8.5 / 2013-05-09
197
+
198
+* [Fix] inotify: allow monitoring of "broken" symlinks (thanks @tsg)
199
+
200
+## v0.8.4 / 2013-04-07
201
+
202
+* [Fix] kqueue: watch all file events [#40][] (thanks @ChrisBuchholz)
203
+
204
+## v0.8.3 / 2013-03-13
205
+
206
+* [Fix] inoitfy/kqueue memory leak [#36][] (reported by @nbkolchin)
207
+* [Fix] kqueue: use fsnFlags for watching a directory [#33][] (reported by @nbkolchin)
208
+
209
+## v0.8.2 / 2013-02-07
210
+
211
+* [Doc] add Authors
212
+* [Fix] fix data races for map access [#29][] (thanks @fsouza)
213
+
214
+## v0.8.1 / 2013-01-09
215
+
216
+* [Fix] Windows path separators
217
+* [Doc] BSD License
218
+
219
+## v0.8.0 / 2012-11-09
220
+
221
+* kqueue: directory watching improvements (thanks @vmirage)
222
+* inotify: add `IN_MOVED_TO` [#25][] (requested by @cpisto)
223
+* [Fix] kqueue: deleting watched directory [#24][] (reported by @jakerr)
224
+
225
+## v0.7.4 / 2012-10-09
226
+
227
+* [Fix] inotify: fixes from https://codereview.appspot.com/5418045/ (ugorji)
228
+* [Fix] kqueue: preserve watch flags when watching for delete [#21][] (reported by @robfig)
229
+* [Fix] kqueue: watch the directory even if it isn't a new watch (thanks @robfig)
230
+* [Fix] kqueue: modify after recreation of file
231
+
232
+## v0.7.3 / 2012-09-27
233
+
234
+* [Fix] kqueue: watch with an existing folder inside the watched folder (thanks @vmirage)
235
+* [Fix] kqueue: no longer get duplicate CREATE events
236
+
237
+## v0.7.2 / 2012-09-01
238
+
239
+* kqueue: events for created directories
240
+
241
+## v0.7.1 / 2012-07-14
242
+
243
+* [Fix] for renaming files
244
+
245
+## v0.7.0 / 2012-07-02
246
+
247
+* [Feature] FSNotify flags
248
+* [Fix] inotify: Added file name back to event path
249
+
250
+## v0.6.0 / 2012-06-06
251
+
252
+* kqueue: watch files after directory created (thanks @tmc)
253
+
254
+## v0.5.1 / 2012-05-22
255
+
256
+* [Fix] inotify: remove all watches before Close()
257
+
258
+## v0.5.0 / 2012-05-03
259
+
260
+* [API] kqueue: return errors during watch instead of sending over channel
261
+* kqueue: match symlink behavior on Linux
262
+* inotify: add `DELETE_SELF` (requested by @taralx)
263
+* [Fix] kqueue: handle EINTR (reported by @robfig)
264
+* [Doc] Godoc example [#1][] (thanks @davecheney)
265
+
266
+## v0.4.0 / 2012-03-30
267
+
268
+* Go 1 released: build with go tool
269
+* [Feature] Windows support using winfsnotify
270
+* Windows does not have attribute change notifications
271
+* Roll attribute notifications into IsModify
272
+
273
+## v0.3.0 / 2012-02-19
274
+
275
+* kqueue: add files when watch directory
276
+
277
+## v0.2.0 / 2011-12-30
278
+
279
+* update to latest Go weekly code
280
+
281
+## v0.1.0 / 2011-10-19
282
+
283
+* kqueue: add watch on file creation to match inotify
284
+* kqueue: create file event
285
+* inotify: ignore `IN_IGNORED` events
286
+* event String()
287
+* linux: common FileEvent functions
288
+* initial commit
289
+
290
+[#79]: https://github.com/howeyc/fsnotify/pull/79
291
+[#77]: https://github.com/howeyc/fsnotify/pull/77
292
+[#72]: https://github.com/howeyc/fsnotify/issues/72
293
+[#71]: https://github.com/howeyc/fsnotify/issues/71
294
+[#70]: https://github.com/howeyc/fsnotify/issues/70
295
+[#63]: https://github.com/howeyc/fsnotify/issues/63
296
+[#62]: https://github.com/howeyc/fsnotify/issues/62
297
+[#60]: https://github.com/howeyc/fsnotify/issues/60
298
+[#59]: https://github.com/howeyc/fsnotify/issues/59
299
+[#49]: https://github.com/howeyc/fsnotify/issues/49
300
+[#45]: https://github.com/howeyc/fsnotify/issues/45
301
+[#40]: https://github.com/howeyc/fsnotify/issues/40
302
+[#36]: https://github.com/howeyc/fsnotify/issues/36
303
+[#33]: https://github.com/howeyc/fsnotify/issues/33
304
+[#29]: https://github.com/howeyc/fsnotify/issues/29
305
+[#25]: https://github.com/howeyc/fsnotify/issues/25
306
+[#24]: https://github.com/howeyc/fsnotify/issues/24
307
+[#21]: https://github.com/howeyc/fsnotify/issues/21

+ 77
- 0
vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md View File

@@ -0,0 +1,77 @@
1
+# Contributing
2
+
3
+## Issues
4
+
5
+* Request features and report bugs using the [GitHub Issue Tracker](https://github.com/fsnotify/fsnotify/issues).
6
+* Please indicate the platform you are using fsnotify on.
7
+* A code example to reproduce the problem is appreciated.
8
+
9
+## Pull Requests
10
+
11
+### Contributor License Agreement
12
+
13
+fsnotify is derived from code in the [golang.org/x/exp](https://godoc.org/golang.org/x/exp) package and it may be included [in the standard library](https://github.com/fsnotify/fsnotify/issues/1) in the future. Therefore fsnotify carries the same [LICENSE](https://github.com/fsnotify/fsnotify/blob/master/LICENSE) as Go. Contributors retain their copyright, so you need to fill out a short form before we can accept your contribution: [Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual).
14
+
15
+Please indicate that you have signed the CLA in your pull request.
16
+
17
+### How fsnotify is Developed
18
+
19
+* Development is done on feature branches.
20
+* Tests are run on BSD, Linux, macOS and Windows.
21
+* Pull requests are reviewed and [applied to master][am] using [hub][].
22
+  * Maintainers may modify or squash commits rather than asking contributors to.
23
+* To issue a new release, the maintainers will:
24
+  * Update the CHANGELOG
25
+  * Tag a version, which will become available through gopkg.in.
26
+ 
27
+### How to Fork
28
+
29
+For smooth sailing, always use the original import path. Installing with `go get` makes this easy. 
30
+
31
+1. Install from GitHub (`go get -u github.com/fsnotify/fsnotify`)
32
+2. Create your feature branch (`git checkout -b my-new-feature`)
33
+3. Ensure everything works and the tests pass (see below)
34
+4. Commit your changes (`git commit -am 'Add some feature'`)
35
+
36
+Contribute upstream:
37
+
38
+1. Fork fsnotify on GitHub
39
+2. Add your remote (`git remote add fork git@github.com:mycompany/repo.git`)
40
+3. Push to the branch (`git push fork my-new-feature`)
41
+4. Create a new Pull Request on GitHub
42
+
43
+This workflow is [thoroughly explained by Katrina Owen](https://splice.com/blog/contributing-open-source-git-repositories-go/).
44
+
45
+### Testing
46
+
47
+fsnotify uses build tags to compile different code on Linux, BSD, macOS, and Windows.
48
+
49
+Before doing a pull request, please do your best to test your changes on multiple platforms, and list which platforms you were able/unable to test on.
50
+
51
+To aid in cross-platform testing there is a Vagrantfile for Linux and BSD.
52
+
53
+* Install [Vagrant](http://www.vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/)
54
+* Setup [Vagrant Gopher](https://github.com/nathany/vagrant-gopher) in your `src` folder.
55
+* Run `vagrant up` from the project folder. You can also setup just one box with `vagrant up linux` or `vagrant up bsd` (note: the BSD box doesn't support Windows hosts at this time, and NFS may prompt for your host OS password)
56
+* Once setup, you can run the test suite on a given OS with a single command `vagrant ssh linux -c 'cd fsnotify/fsnotify; go test'`.
57
+* When you're done, you will want to halt or destroy the Vagrant boxes.
58
+
59
+Notice: fsnotify file system events won't trigger in shared folders. The tests get around this limitation by using the /tmp directory.
60
+
61
+Right now there is no equivalent solution for Windows and macOS, but there are Windows VMs [freely available from Microsoft](http://www.modern.ie/en-us/virtualization-tools#downloads).
62
+
63
+### Maintainers
64
+
65
+Help maintaining fsnotify is welcome. To be a maintainer:
66
+
67
+* Submit a pull request and sign the CLA as above.
68
+* You must be able to run the test suite on Mac, Windows, Linux and BSD.
69
+
70
+To keep master clean, the fsnotify project uses the "apply mail" workflow outlined in Nathaniel Talbott's post ["Merge pull request" Considered Harmful][am]. This requires installing [hub][].
71
+
72
+All code changes should be internal pull requests.
73
+
74
+Releases are tagged using [Semantic Versioning](http://semver.org/).
75
+
76
+[hub]: https://github.com/github/hub
77
+[am]: http://blog.spreedly.com/2014/06/24/merge-pull-request-considered-harmful/#.VGa5yZPF_Zs

+ 28
- 0
vendor/github.com/fsnotify/fsnotify/LICENSE View File

@@ -0,0 +1,28 @@
1
+Copyright (c) 2012 The Go Authors. All rights reserved.
2
+Copyright (c) 2012 fsnotify Authors. All rights reserved.
3
+
4
+Redistribution and use in source and binary forms, with or without
5
+modification, are permitted provided that the following conditions are
6
+met:
7
+
8
+   * Redistributions of source code must retain the above copyright
9
+notice, this list of conditions and the following disclaimer.
10
+   * Redistributions in binary form must reproduce the above
11
+copyright notice, this list of conditions and the following disclaimer
12
+in the documentation and/or other materials provided with the
13
+distribution.
14
+   * Neither the name of Google Inc. nor the names of its
15
+contributors may be used to endorse or promote products derived from
16
+this software without specific prior written permission.
17
+
18
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 79
- 0
vendor/github.com/fsnotify/fsnotify/README.md View File

@@ -0,0 +1,79 @@
1
+# File system notifications for Go
2
+
3
+[![GoDoc](https://godoc.org/github.com/fsnotify/fsnotify?status.svg)](https://godoc.org/github.com/fsnotify/fsnotify) [![Go Report Card](https://goreportcard.com/badge/github.com/fsnotify/fsnotify)](https://goreportcard.com/report/github.com/fsnotify/fsnotify)
4
+
5
+fsnotify utilizes [golang.org/x/sys](https://godoc.org/golang.org/x/sys) rather than `syscall` from the standard library. Ensure you have the latest version installed by running:
6
+
7
+```console
8
+go get -u golang.org/x/sys/...
9
+```
10
+
11
+Cross platform: Windows, Linux, BSD and macOS.
12
+
13
+|Adapter   |OS        |Status    |
14
+|----------|----------|----------|
15
+|inotify   |Linux 2.6.27 or later, Android\*|Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify)|
16
+|kqueue    |BSD, macOS, iOS\*|Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify)|
17
+|ReadDirectoryChangesW|Windows|Supported [![Build status](https://ci.appveyor.com/api/projects/status/ivwjubaih4r0udeh/branch/master?svg=true)](https://ci.appveyor.com/project/NathanYoungman/fsnotify/branch/master)|
18
+|FSEvents  |macOS         |[Planned](https://github.com/fsnotify/fsnotify/issues/11)|
19
+|FEN       |Solaris 11    |[In Progress](https://github.com/fsnotify/fsnotify/issues/12)|
20
+|fanotify  |Linux 2.6.37+ | |
21
+|USN Journals |Windows    |[Maybe](https://github.com/fsnotify/fsnotify/issues/53)|
22
+|Polling   |*All*         |[Maybe](https://github.com/fsnotify/fsnotify/issues/9)|
23
+
24
+\* Android and iOS are untested.
25
+
26
+Please see [the documentation](https://godoc.org/github.com/fsnotify/fsnotify) and consult the [FAQ](#faq) for usage information.
27
+
28
+## API stability
29
+
30
+fsnotify is a fork of [howeyc/fsnotify](https://godoc.org/github.com/howeyc/fsnotify) with a new API as of v1.0. The API is based on [this design document](http://goo.gl/MrYxyA). 
31
+
32
+All [releases](https://github.com/fsnotify/fsnotify/releases) are tagged based on [Semantic Versioning](http://semver.org/). Further API changes are [planned](https://github.com/fsnotify/fsnotify/milestones), and will be tagged with a new major revision number.
33
+
34
+Go 1.6 supports dependencies located in the `vendor/` folder. Unless you are creating a library, it is recommended that you copy fsnotify into `vendor/github.com/fsnotify/fsnotify` within your project, and likewise for `golang.org/x/sys`.
35
+
36
+## Contributing
37
+
38
+Please refer to [CONTRIBUTING][] before opening an issue or pull request.
39
+
40
+## Example
41
+
42
+See [example_test.go](https://github.com/fsnotify/fsnotify/blob/master/example_test.go).
43
+
44
+## FAQ
45
+
46
+**When a file is moved to another directory is it still being watched?**
47
+
48
+No (it shouldn't be, unless you are watching where it was moved to).
49
+
50
+**When I watch a directory, are all subdirectories watched as well?**
51
+
52
+No, you must add watches for any directory you want to watch (a recursive watcher is on the roadmap [#18][]).
53
+
54
+**Do I have to watch the Error and Event channels in a separate goroutine?**
55
+
56
+As of now, yes. Looking into making this single-thread friendly (see [howeyc #7][#7])
57
+
58
+**Why am I receiving multiple events for the same file on OS X?**
59
+
60
+Spotlight indexing on OS X can result in multiple events (see [howeyc #62][#62]). A temporary workaround is to add your folder(s) to the *Spotlight Privacy settings* until we have a native FSEvents implementation (see [#11][]).
61
+
62
+**How many files can be watched at once?**
63
+
64
+There are OS-specific limits as to how many watches can be created:
65
+* Linux: /proc/sys/fs/inotify/max_user_watches contains the limit, reaching this limit results in a "no space left on device" error.
66
+* BSD / OSX: sysctl variables "kern.maxfiles" and "kern.maxfilesperproc", reaching these limits results in a "too many open files" error.
67
+
68
+[#62]: https://github.com/howeyc/fsnotify/issues/62
69
+[#18]: https://github.com/fsnotify/fsnotify/issues/18
70
+[#11]: https://github.com/fsnotify/fsnotify/issues/11
71
+[#7]: https://github.com/howeyc/fsnotify/issues/7
72
+
73
+[contributing]: https://github.com/fsnotify/fsnotify/blob/master/CONTRIBUTING.md
74
+
75
+## Related Projects
76
+
77
+* [notify](https://github.com/rjeczalik/notify)
78
+* [fsevents](https://github.com/fsnotify/fsevents)
79
+

+ 42
- 0
vendor/github.com/fsnotify/fsnotify/example_test.go View File

@@ -0,0 +1,42 @@
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 !plan9
6
+
7
+package fsnotify_test
8
+
9
+import (
10
+	"log"
11
+
12
+	"github.com/fsnotify/fsnotify"
13
+)
14
+
15
+func ExampleNewWatcher() {
16
+	watcher, err := fsnotify.NewWatcher()
17
+	if err != nil {
18
+		log.Fatal(err)
19
+	}
20
+	defer watcher.Close()
21
+
22
+	done := make(chan bool)
23
+	go func() {
24
+		for {
25
+			select {
26
+			case event := <-watcher.Events:
27
+				log.Println("event:", event)
28
+				if event.Op&fsnotify.Write == fsnotify.Write {
29
+					log.Println("modified file:", event.Name)
30
+				}
31
+			case err := <-watcher.Errors:
32
+				log.Println("error:", err)
33
+			}
34
+		}
35
+	}()
36
+
37
+	err = watcher.Add("/tmp/foo")
38
+	if err != nil {
39
+		log.Fatal(err)
40
+	}
41
+	<-done
42
+}

+ 37
- 0
vendor/github.com/fsnotify/fsnotify/fen.go View File

@@ -0,0 +1,37 @@
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 solaris
6
+
7
+package fsnotify
8
+
9
+import (
10
+	"errors"
11
+)
12
+
13
+// Watcher watches a set of files, delivering events to a channel.
14
+type Watcher struct {
15
+	Events chan Event
16
+	Errors chan error
17
+}
18
+
19
+// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
20
+func NewWatcher() (*Watcher, error) {
21
+	return nil, errors.New("FEN based watcher not yet supported for fsnotify\n")
22
+}
23
+
24
+// Close removes all watches and closes the events channel.
25
+func (w *Watcher) Close() error {
26
+	return nil
27
+}
28
+
29
+// Add starts watching the named file or directory (non-recursively).
30
+func (w *Watcher) Add(name string) error {
31
+	return nil
32
+}
33
+
34
+// Remove stops watching the the named file or directory (non-recursively).
35
+func (w *Watcher) Remove(name string) error {
36
+	return nil
37
+}

+ 66
- 0
vendor/github.com/fsnotify/fsnotify/fsnotify.go View File

@@ -0,0 +1,66 @@
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 !plan9
6
+
7
+// Package fsnotify provides a platform-independent interface for file system notifications.
8
+package fsnotify
9
+
10
+import (
11
+	"bytes"
12
+	"errors"
13
+	"fmt"
14
+)
15
+
16
+// Event represents a single file system notification.
17
+type Event struct {
18
+	Name string // Relative path to the file or directory.
19
+	Op   Op     // File operation that triggered the event.
20
+}
21
+
22
+// Op describes a set of file operations.
23
+type Op uint32
24
+
25
+// These are the generalized file operations that can trigger a notification.
26
+const (
27
+	Create Op = 1 << iota
28
+	Write
29
+	Remove
30
+	Rename
31
+	Chmod
32
+)
33
+
34
+func (op Op) String() string {
35
+	// Use a buffer for efficient string concatenation
36
+	var buffer bytes.Buffer
37
+
38
+	if op&Create == Create {
39
+		buffer.WriteString("|CREATE")
40
+	}
41
+	if op&Remove == Remove {
42
+		buffer.WriteString("|REMOVE")
43
+	}
44
+	if op&Write == Write {
45
+		buffer.WriteString("|WRITE")
46
+	}
47
+	if op&Rename == Rename {
48
+		buffer.WriteString("|RENAME")
49
+	}
50
+	if op&Chmod == Chmod {
51
+		buffer.WriteString("|CHMOD")
52
+	}
53
+	if buffer.Len() == 0 {
54
+		return ""
55
+	}
56
+	return buffer.String()[1:] // Strip leading pipe
57
+}
58
+
59
+// String returns a string representation of the event in the form
60
+// "file: REMOVE|WRITE|..."
61
+func (e Event) String() string {
62
+	return fmt.Sprintf("%q: %s", e.Name, e.Op.String())
63
+}
64
+
65
+// Common errors that can be reported by a watcher
66
+var ErrEventOverflow = errors.New("fsnotify queue overflow")

+ 40
- 0
vendor/github.com/fsnotify/fsnotify/fsnotify_test.go View File

@@ -0,0 +1,40 @@
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 !plan9
6
+
7
+package fsnotify
8
+
9
+import "testing"
10
+
11
+func TestEventStringWithValue(t *testing.T) {
12
+	for opMask, expectedString := range map[Op]string{
13
+		Chmod | Create: `"/usr/someFile": CREATE|CHMOD`,
14
+		Rename:         `"/usr/someFile": RENAME`,
15
+		Remove:         `"/usr/someFile": REMOVE`,
16
+		Write | Chmod:  `"/usr/someFile": WRITE|CHMOD`,
17
+	} {
18
+		event := Event{Name: "/usr/someFile", Op: opMask}
19
+		if event.String() != expectedString {
20
+			t.Fatalf("Expected %s, got: %v", expectedString, event.String())
21
+		}
22
+
23
+	}
24
+}
25
+
26
+func TestEventOpStringWithValue(t *testing.T) {
27
+	expectedOpString := "WRITE|CHMOD"
28
+	event := Event{Name: "someFile", Op: Write | Chmod}
29
+	if event.Op.String() != expectedOpString {
30
+		t.Fatalf("Expected %s, got: %v", expectedOpString, event.Op.String())
31
+	}
32
+}
33
+
34
+func TestEventOpStringWithNoValue(t *testing.T) {
35
+	expectedOpString := ""
36
+	event := Event{Name: "testFile", Op: 0}
37
+	if event.Op.String() != expectedOpString {
38
+		t.Fatalf("Expected %s, got: %v", expectedOpString, event.Op.String())
39
+	}
40
+}

+ 337
- 0
vendor/github.com/fsnotify/fsnotify/inotify.go View File

@@ -0,0 +1,337 @@
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 linux
6
+
7
+package fsnotify
8
+
9
+import (
10
+	"errors"
11
+	"fmt"
12
+	"io"
13
+	"os"
14
+	"path/filepath"
15
+	"strings"
16
+	"sync"
17
+	"unsafe"
18
+
19
+	"golang.org/x/sys/unix"
20
+)
21
+
22
+// Watcher watches a set of files, delivering events to a channel.
23
+type Watcher struct {
24
+	Events   chan Event
25
+	Errors   chan error
26
+	mu       sync.Mutex // Map access
27
+	fd       int
28
+	poller   *fdPoller
29
+	watches  map[string]*watch // Map of inotify watches (key: path)
30
+	paths    map[int]string    // Map of watched paths (key: watch descriptor)
31
+	done     chan struct{}     // Channel for sending a "quit message" to the reader goroutine
32
+	doneResp chan struct{}     // Channel to respond to Close
33
+}
34
+
35
+// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
36
+func NewWatcher() (*Watcher, error) {
37
+	// Create inotify fd
38
+	fd, errno := unix.InotifyInit1(unix.IN_CLOEXEC)
39
+	if fd == -1 {
40
+		return nil, errno
41
+	}
42
+	// Create epoll
43
+	poller, err := newFdPoller(fd)
44
+	if err != nil {
45
+		unix.Close(fd)
46
+		return nil, err
47
+	}
48
+	w := &Watcher{
49
+		fd:       fd,
50
+		poller:   poller,
51
+		watches:  make(map[string]*watch),
52
+		paths:    make(map[int]string),
53
+		Events:   make(chan Event),
54
+		Errors:   make(chan error),
55
+		done:     make(chan struct{}),
56
+		doneResp: make(chan struct{}),
57
+	}
58
+
59
+	go w.readEvents()
60
+	return w, nil
61
+}
62
+
63
+func (w *Watcher) isClosed() bool {
64
+	select {
65
+	case <-w.done:
66
+		return true
67
+	default:
68
+		return false
69
+	}
70
+}
71
+
72
+// Close removes all watches and closes the events channel.
73
+func (w *Watcher) Close() error {
74
+	if w.isClosed() {
75
+		return nil
76
+	}
77
+
78
+	// Send 'close' signal to goroutine, and set the Watcher to closed.
79
+	close(w.done)
80
+
81
+	// Wake up goroutine
82
+	w.poller.wake()
83
+
84
+	// Wait for goroutine to close
85
+	<-w.doneResp
86
+
87
+	return nil
88
+}
89
+
90
+// Add starts watching the named file or directory (non-recursively).
91
+func (w *Watcher) Add(name string) error {
92
+	name = filepath.Clean(name)
93
+	if w.isClosed() {
94
+		return errors.New("inotify instance already closed")
95
+	}
96
+
97
+	const agnosticEvents = unix.IN_MOVED_TO | unix.IN_MOVED_FROM |
98
+		unix.IN_CREATE | unix.IN_ATTRIB | unix.IN_MODIFY |
99
+		unix.IN_MOVE_SELF | unix.IN_DELETE | unix.IN_DELETE_SELF
100
+
101
+	var flags uint32 = agnosticEvents
102
+
103
+	w.mu.Lock()
104
+	defer w.mu.Unlock()
105
+	watchEntry := w.watches[name]
106
+	if watchEntry != nil {
107
+		flags |= watchEntry.flags | unix.IN_MASK_ADD
108
+	}
109
+	wd, errno := unix.InotifyAddWatch(w.fd, name, flags)
110
+	if wd == -1 {
111
+		return errno
112
+	}
113
+
114
+	if watchEntry == nil {
115
+		w.watches[name] = &watch{wd: uint32(wd), flags: flags}
116
+		w.paths[wd] = name
117
+	} else {
118
+		watchEntry.wd = uint32(wd)
119
+		watchEntry.flags = flags
120
+	}
121
+
122
+	return nil
123
+}
124
+
125
+// Remove stops watching the named file or directory (non-recursively).
126
+func (w *Watcher) Remove(name string) error {
127
+	name = filepath.Clean(name)
128
+
129
+	// Fetch the watch.
130
+	w.mu.Lock()
131
+	defer w.mu.Unlock()
132
+	watch, ok := w.watches[name]
133
+
134
+	// Remove it from inotify.
135
+	if !ok {
136
+		return fmt.Errorf("can't remove non-existent inotify watch for: %s", name)
137
+	}
138
+
139
+	// We successfully removed the watch if InotifyRmWatch doesn't return an
140
+	// error, we need to clean up our internal state to ensure it matches
141
+	// inotify's kernel state.
142
+	delete(w.paths, int(watch.wd))
143
+	delete(w.watches, name)
144
+
145
+	// inotify_rm_watch will return EINVAL if the file has been deleted;
146
+	// the inotify will already have been removed.
147
+	// watches and pathes are deleted in ignoreLinux() implicitly and asynchronously
148
+	// by calling inotify_rm_watch() below. e.g. readEvents() goroutine receives IN_IGNORE
149
+	// so that EINVAL means that the wd is being rm_watch()ed or its file removed
150
+	// by another thread and we have not received IN_IGNORE event.
151
+	success, errno := unix.InotifyRmWatch(w.fd, watch.wd)
152
+	if success == -1 {
153
+		// TODO: Perhaps it's not helpful to return an error here in every case.
154
+		// the only two possible errors are:
155
+		// EBADF, which happens when w.fd is not a valid file descriptor of any kind.
156
+		// EINVAL, which is when fd is not an inotify descriptor or wd is not a valid watch descriptor.
157
+		// Watch descriptors are invalidated when they are removed explicitly or implicitly;
158
+		// explicitly by inotify_rm_watch, implicitly when the file they are watching is deleted.
159
+		return errno
160
+	}
161
+
162
+	return nil
163
+}
164
+
165
+type watch struct {
166
+	wd    uint32 // Watch descriptor (as returned by the inotify_add_watch() syscall)
167
+	flags uint32 // inotify flags of this watch (see inotify(7) for the list of valid flags)
168
+}
169
+
170
+// readEvents reads from the inotify file descriptor, converts the
171
+// received events into Event objects and sends them via the Events channel
172
+func (w *Watcher) readEvents() {
173
+	var (
174
+		buf   [unix.SizeofInotifyEvent * 4096]byte // Buffer for a maximum of 4096 raw events
175
+		n     int                                  // Number of bytes read with read()
176
+		errno error                                // Syscall errno
177
+		ok    bool                                 // For poller.wait
178
+	)
179
+
180
+	defer close(w.doneResp)
181
+	defer close(w.Errors)
182
+	defer close(w.Events)
183
+	defer unix.Close(w.fd)
184
+	defer w.poller.close()
185
+
186
+	for {
187
+		// See if we have been closed.
188
+		if w.isClosed() {
189
+			return
190
+		}
191
+
192
+		ok, errno = w.poller.wait()
193
+		if errno != nil {
194
+			select {
195
+			case w.Errors <- errno:
196
+			case <-w.done:
197
+				return
198
+			}
199
+			continue
200
+		}
201
+
202
+		if !ok {
203
+			continue
204
+		}
205
+
206
+		n, errno = unix.Read(w.fd, buf[:])
207
+		// If a signal interrupted execution, see if we've been asked to close, and try again.
208
+		// http://man7.org/linux/man-pages/man7/signal.7.html :
209
+		// "Before Linux 3.8, reads from an inotify(7) file descriptor were not restartable"
210
+		if errno == unix.EINTR {
211
+			continue
212
+		}
213
+
214
+		// unix.Read might have been woken up by Close. If so, we're done.
215
+		if w.isClosed() {
216
+			return
217
+		}
218
+
219
+		if n < unix.SizeofInotifyEvent {
220
+			var err error
221
+			if n == 0 {
222
+				// If EOF is received. This should really never happen.
223
+				err = io.EOF
224
+			} else if n < 0 {
225
+				// If an error occurred while reading.
226
+				err = errno
227
+			} else {
228
+				// Read was too short.
229
+				err = errors.New("notify: short read in readEvents()")
230
+			}
231
+			select {
232
+			case w.Errors <- err:
233
+			case <-w.done:
234
+				return
235
+			}
236
+			continue
237
+		}
238
+
239
+		var offset uint32
240
+		// We don't know how many events we just read into the buffer
241
+		// While the offset points to at least one whole event...
242
+		for offset <= uint32(n-unix.SizeofInotifyEvent) {
243
+			// Point "raw" to the event in the buffer
244
+			raw := (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset]))
245
+
246
+			mask := uint32(raw.Mask)
247
+			nameLen := uint32(raw.Len)
248
+
249
+			if mask&unix.IN_Q_OVERFLOW != 0 {
250
+				select {
251
+				case w.Errors <- ErrEventOverflow:
252
+				case <-w.done:
253
+					return
254
+				}
255
+			}
256
+
257
+			// If the event happened to the watched directory or the watched file, the kernel
258
+			// doesn't append the filename to the event, but we would like to always fill the
259
+			// the "Name" field with a valid filename. We retrieve the path of the watch from
260
+			// the "paths" map.
261
+			w.mu.Lock()
262
+			name, ok := w.paths[int(raw.Wd)]
263
+			// IN_DELETE_SELF occurs when the file/directory being watched is removed.
264
+			// This is a sign to clean up the maps, otherwise we are no longer in sync
265
+			// with the inotify kernel state which has already deleted the watch
266
+			// automatically.
267
+			if ok && mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF {
268
+				delete(w.paths, int(raw.Wd))
269
+				delete(w.watches, name)
270
+			}
271
+			w.mu.Unlock()
272
+
273
+			if nameLen > 0 {
274
+				// Point "bytes" at the first byte of the filename
275
+				bytes := (*[unix.PathMax]byte)(unsafe.Pointer(&buf[offset+unix.SizeofInotifyEvent]))
276
+				// The filename is padded with NULL bytes. TrimRight() gets rid of those.
277
+				name += "/" + strings.TrimRight(string(bytes[0:nameLen]), "\000")
278
+			}
279
+
280
+			event := newEvent(name, mask)
281
+
282
+			// Send the events that are not ignored on the events channel
283
+			if !event.ignoreLinux(mask) {
284
+				select {
285
+				case w.Events <- event:
286
+				case <-w.done:
287
+					return
288
+				}
289
+			}
290
+
291
+			// Move to the next event in the buffer
292
+			offset += unix.SizeofInotifyEvent + nameLen
293
+		}
294
+	}
295
+}
296
+
297
+// Certain types of events can be "ignored" and not sent over the Events
298
+// channel. Such as events marked ignore by the kernel, or MODIFY events
299
+// against files that do not exist.
300
+func (e *Event) ignoreLinux(mask uint32) bool {
301
+	// Ignore anything the inotify API says to ignore
302
+	if mask&unix.IN_IGNORED == unix.IN_IGNORED {
303
+		return true
304
+	}
305
+
306
+	// If the event is not a DELETE or RENAME, the file must exist.
307
+	// Otherwise the event is ignored.
308
+	// *Note*: this was put in place because it was seen that a MODIFY
309
+	// event was sent after the DELETE. This ignores that MODIFY and
310
+	// assumes a DELETE will come or has come if the file doesn't exist.
311
+	if !(e.Op&Remove == Remove || e.Op&Rename == Rename) {
312
+		_, statErr := os.Lstat(e.Name)
313
+		return os.IsNotExist(statErr)
314
+	}
315
+	return false
316
+}
317
+
318
+// newEvent returns an platform-independent Event based on an inotify mask.
319
+func newEvent(name string, mask uint32) Event {
320
+	e := Event{Name: name}
321
+	if mask&unix.IN_CREATE == unix.IN_CREATE || mask&unix.IN_MOVED_TO == unix.IN_MOVED_TO {
322
+		e.Op |= Create
323
+	}
324
+	if mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF || mask&unix.IN_DELETE == unix.IN_DELETE {
325
+		e.Op |= Remove
326
+	}
327
+	if mask&unix.IN_MODIFY == unix.IN_MODIFY {
328
+		e.Op |= Write
329
+	}
330
+	if mask&unix.IN_MOVE_SELF == unix.IN_MOVE_SELF || mask&unix.IN_MOVED_FROM == unix.IN_MOVED_FROM {
331
+		e.Op |= Rename
332
+	}
333
+	if mask&unix.IN_ATTRIB == unix.IN_ATTRIB {
334
+		e.Op |= Chmod
335
+	}
336
+	return e
337
+}

+ 187
- 0
vendor/github.com/fsnotify/fsnotify/inotify_poller.go View File

@@ -0,0 +1,187 @@
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
+
7
+package fsnotify
8
+
9
+import (
10
+	"errors"
11
+
12
+	"golang.org/x/sys/unix"
13
+)
14
+
15
+type fdPoller struct {
16
+	fd   int    // File descriptor (as returned by the inotify_init() syscall)
17
+	epfd int    // Epoll file descriptor
18
+	pipe [2]int // Pipe for waking up
19
+}
20
+
21
+func emptyPoller(fd int) *fdPoller {
22
+	poller := new(fdPoller)
23
+	poller.fd = fd
24
+	poller.epfd = -1
25
+	poller.pipe[0] = -1
26
+	poller.pipe[1] = -1
27
+	return poller
28
+}
29
+
30
+// Create a new inotify poller.
31
+// This creates an inotify handler, and an epoll handler.
32
+func newFdPoller(fd int) (*fdPoller, error) {
33
+	var errno error
34
+	poller := emptyPoller(fd)
35
+	defer func() {
36
+		if errno != nil {
37
+			poller.close()
38
+		}
39
+	}()
40
+	poller.fd = fd
41
+
42
+	// Create epoll fd
43
+	poller.epfd, errno = unix.EpollCreate1(0)
44
+	if poller.epfd == -1 {
45
+		return nil, errno
46
+	}
47
+	// Create pipe; pipe[0] is the read end, pipe[1] the write end.
48
+	errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK)
49
+	if errno != nil {
50
+		return nil, errno
51
+	}
52
+
53
+	// Register inotify fd with epoll
54
+	event := unix.EpollEvent{
55
+		Fd:     int32(poller.fd),
56
+		Events: unix.EPOLLIN,
57
+	}
58
+	errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.fd, &event)
59
+	if errno != nil {
60
+		return nil, errno
61
+	}
62
+
63
+	// Register pipe fd with epoll
64
+	event = unix.EpollEvent{
65
+		Fd:     int32(poller.pipe[0]),
66
+		Events: unix.EPOLLIN,
67
+	}
68
+	errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.pipe[0], &event)
69
+	if errno != nil {
70
+		return nil, errno
71
+	}
72
+
73
+	return poller, nil
74
+}
75
+
76
+// Wait using epoll.
77
+// Returns true if something is ready to be read,
78
+// false if there is not.
79
+func (poller *fdPoller) wait() (bool, error) {
80
+	// 3 possible events per fd, and 2 fds, makes a maximum of 6 events.
81
+	// I don't know whether epoll_wait returns the number of events returned,
82
+	// or the total number of events ready.
83
+	// I decided to catch both by making the buffer one larger than the maximum.
84
+	events := make([]unix.EpollEvent, 7)
85
+	for {
86
+		n, errno := unix.EpollWait(poller.epfd, events, -1)
87
+		if n == -1 {
88
+			if errno == unix.EINTR {
89
+				continue
90
+			}
91
+			return false, errno
92
+		}
93
+		if n == 0 {
94
+			// If there are no events, try again.
95
+			continue
96
+		}
97
+		if n > 6 {
98
+			// This should never happen. More events were returned than should be possible.
99
+			return false, errors.New("epoll_wait returned more events than I know what to do with")
100
+		}
101
+		ready := events[:n]
102
+		epollhup := false
103
+		epollerr := false
104
+		epollin := false
105
+		for _, event := range ready {
106
+			if event.Fd == int32(poller.fd) {
107
+				if event.Events&unix.EPOLLHUP != 0 {
108
+					// This should not happen, but if it does, treat it as a wakeup.
109
+					epollhup = true
110
+				}
111
+				if event.Events&unix.EPOLLERR != 0 {
112
+					// If an error is waiting on the file descriptor, we should pretend
113
+					// something is ready to read, and let unix.Read pick up the error.
114
+					epollerr = true
115
+				}
116
+				if event.Events&unix.EPOLLIN != 0 {
117
+					// There is data to read.
118
+					epollin = true
119
+				}
120
+			}
121
+			if event.Fd == int32(poller.pipe[0]) {
122
+				if event.Events&unix.EPOLLHUP != 0 {
123
+					// Write pipe descriptor was closed, by us. This means we're closing down the
124
+					// watcher, and we should wake up.
125
+				}
126
+				if event.Events&unix.EPOLLERR != 0 {
127
+					// If an error is waiting on the pipe file descriptor.
128
+					// This is an absolute mystery, and should never ever happen.
129
+					return false, errors.New("Error on the pipe descriptor.")
130
+				}
131
+				if event.Events&unix.EPOLLIN != 0 {
132
+					// This is a regular wakeup, so we have to clear the buffer.
133
+					err := poller.clearWake()
134
+					if err != nil {
135
+						return false, err
136
+					}
137
+				}
138
+			}
139
+		}
140
+
141
+		if epollhup || epollerr || epollin {
142
+			return true, nil
143
+		}
144
+		return false, nil
145
+	}
146
+}
147
+
148
+// Close the write end of the poller.
149
+func (poller *fdPoller) wake() error {
150
+	buf := make([]byte, 1)
151
+	n, errno := unix.Write(poller.pipe[1], buf)
152
+	if n == -1 {
153
+		if errno == unix.EAGAIN {
154
+			// Buffer is full, poller will wake.
155
+			return nil
156
+		}
157
+		return errno
158
+	}
159
+	return nil
160
+}
161
+
162
+func (poller *fdPoller) clearWake() error {
163
+	// You have to be woken up a LOT in order to get to 100!
164
+	buf := make([]byte, 100)
165
+	n, errno := unix.Read(poller.pipe[0], buf)
166
+	if n == -1 {
167
+		if errno == unix.EAGAIN {
168
+			// Buffer is empty, someone else cleared our wake.
169
+			return nil
170
+		}
171
+		return errno
172
+	}
173
+	return nil
174
+}
175
+
176
+// Close all poller file descriptors, but not the one passed to it.
177
+func (poller *fdPoller) close() {
178
+	if poller.pipe[1] != -1 {
179
+		unix.Close(poller.pipe[1])
180
+	}
181
+	if poller.pipe[0] != -1 {
182
+		unix.Close(poller.pipe[0])
183
+	}
184
+	if poller.epfd != -1 {
185
+		unix.Close(poller.epfd)
186
+	}
187
+}

+ 229
- 0
vendor/github.com/fsnotify/fsnotify/inotify_poller_test.go View File

@@ -0,0 +1,229 @@
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
+
7
+package fsnotify
8
+
9
+import (
10
+	"testing"
11
+	"time"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+type testFd [2]int
17
+
18
+func makeTestFd(t *testing.T) testFd {
19
+	var tfd testFd
20
+	errno := unix.Pipe(tfd[:])
21
+	if errno != nil {
22
+		t.Fatalf("Failed to create pipe: %v", errno)
23
+	}
24
+	return tfd
25
+}
26
+
27
+func (tfd testFd) fd() int {
28
+	return tfd[0]
29
+}
30
+
31
+func (tfd testFd) closeWrite(t *testing.T) {
32
+	errno := unix.Close(tfd[1])
33
+	if errno != nil {
34
+		t.Fatalf("Failed to close write end of pipe: %v", errno)
35
+	}
36
+}
37
+
38
+func (tfd testFd) put(t *testing.T) {
39
+	buf := make([]byte, 10)
40
+	_, errno := unix.Write(tfd[1], buf)
41
+	if errno != nil {
42
+		t.Fatalf("Failed to write to pipe: %v", errno)
43
+	}
44
+}
45
+
46
+func (tfd testFd) get(t *testing.T) {
47
+	buf := make([]byte, 10)
48
+	_, errno := unix.Read(tfd[0], buf)
49
+	if errno != nil {
50
+		t.Fatalf("Failed to read from pipe: %v", errno)
51
+	}
52
+}
53
+
54
+func (tfd testFd) close() {
55
+	unix.Close(tfd[1])
56
+	unix.Close(tfd[0])
57
+}
58
+
59
+func makePoller(t *testing.T) (testFd, *fdPoller) {
60
+	tfd := makeTestFd(t)
61
+	poller, err := newFdPoller(tfd.fd())
62
+	if err != nil {
63
+		t.Fatalf("Failed to create poller: %v", err)
64
+	}
65
+	return tfd, poller
66
+}
67
+
68
+func TestPollerWithBadFd(t *testing.T) {
69
+	_, err := newFdPoller(-1)
70
+	if err != unix.EBADF {
71
+		t.Fatalf("Expected EBADF, got: %v", err)
72
+	}
73
+}
74
+
75
+func TestPollerWithData(t *testing.T) {
76
+	tfd, poller := makePoller(t)
77
+	defer tfd.close()
78
+	defer poller.close()
79
+
80
+	tfd.put(t)
81
+	ok, err := poller.wait()
82
+	if err != nil {
83
+		t.Fatalf("poller failed: %v", err)
84
+	}
85
+	if !ok {
86
+		t.Fatalf("expected poller to return true")
87
+	}
88
+	tfd.get(t)
89
+}
90
+
91
+func TestPollerWithWakeup(t *testing.T) {
92
+	tfd, poller := makePoller(t)
93
+	defer tfd.close()
94
+	defer poller.close()
95
+
96
+	err := poller.wake()
97
+	if err != nil {
98
+		t.Fatalf("wake failed: %v", err)
99
+	}
100
+	ok, err := poller.wait()
101
+	if err != nil {
102
+		t.Fatalf("poller failed: %v", err)
103
+	}
104
+	if ok {
105
+		t.Fatalf("expected poller to return false")
106
+	}
107
+}
108
+
109
+func TestPollerWithClose(t *testing.T) {
110
+	tfd, poller := makePoller(t)
111
+	defer tfd.close()
112
+	defer poller.close()
113
+
114
+	tfd.closeWrite(t)
115
+	ok, err := poller.wait()
116
+	if err != nil {
117
+		t.Fatalf("poller failed: %v", err)
118
+	}
119
+	if !ok {
120
+		t.Fatalf("expected poller to return true")
121
+	}
122
+}
123
+
124
+func TestPollerWithWakeupAndData(t *testing.T) {
125
+	tfd, poller := makePoller(t)
126
+	defer tfd.close()
127
+	defer poller.close()
128
+
129
+	tfd.put(t)
130
+	err := poller.wake()
131
+	if err != nil {
132
+		t.Fatalf("wake failed: %v", err)
133
+	}
134
+
135
+	// both data and wakeup
136
+	ok, err := poller.wait()
137
+	if err != nil {
138
+		t.Fatalf("poller failed: %v", err)
139
+	}
140
+	if !ok {
141
+		t.Fatalf("expected poller to return true")
142
+	}
143
+
144
+	// data is still in the buffer, wakeup is cleared
145
+	ok, err = poller.wait()
146
+	if err != nil {
147
+		t.Fatalf("poller failed: %v", err)
148
+	}
149
+	if !ok {
150
+		t.Fatalf("expected poller to return true")
151
+	}
152
+
153
+	tfd.get(t)
154
+	// data is gone, only wakeup now
155
+	err = poller.wake()
156
+	if err != nil {
157
+		t.Fatalf("wake failed: %v", err)
158
+	}
159
+	ok, err = poller.wait()
160
+	if err != nil {
161
+		t.Fatalf("poller failed: %v", err)
162
+	}
163
+	if ok {
164
+		t.Fatalf("expected poller to return false")
165
+	}
166
+}
167
+
168
+func TestPollerConcurrent(t *testing.T) {
169
+	tfd, poller := makePoller(t)
170
+	defer tfd.close()
171
+	defer poller.close()
172
+
173
+	oks := make(chan bool)
174
+	live := make(chan bool)
175
+	defer close(live)
176
+	go func() {
177
+		defer close(oks)
178
+		for {
179
+			ok, err := poller.wait()
180
+			if err != nil {
181
+				t.Fatalf("poller failed: %v", err)
182
+			}
183
+			oks <- ok
184
+			if !<-live {
185
+				return
186
+			}
187
+		}
188
+	}()
189
+
190
+	// Try a write
191
+	select {
192
+	case <-time.After(50 * time.Millisecond):
193
+	case <-oks:
194
+		t.Fatalf("poller did not wait")
195
+	}
196
+	tfd.put(t)
197
+	if !<-oks {
198
+		t.Fatalf("expected true")
199
+	}
200
+	tfd.get(t)
201
+	live <- true
202
+
203
+	// Try a wakeup
204
+	select {
205
+	case <-time.After(50 * time.Millisecond):
206
+	case <-oks:
207
+		t.Fatalf("poller did not wait")
208
+	}
209
+	err := poller.wake()
210
+	if err != nil {
211
+		t.Fatalf("wake failed: %v", err)
212
+	}
213
+	if <-oks {
214
+		t.Fatalf("expected false")
215
+	}
216
+	live <- true
217
+
218
+	// Try a close
219
+	select {
220
+	case <-time.After(50 * time.Millisecond):
221
+	case <-oks:
222
+		t.Fatalf("poller did not wait")
223
+	}
224
+	tfd.closeWrite(t)
225
+	if !<-oks {
226
+		t.Fatalf("expected true")
227
+	}
228
+	tfd.get(t)
229
+}

+ 449
- 0
vendor/github.com/fsnotify/fsnotify/inotify_test.go View File

@@ -0,0 +1,449 @@
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
+
7
+package fsnotify
8
+
9
+import (
10
+	"fmt"
11
+	"os"
12
+	"path/filepath"
13
+	"strings"
14
+	"testing"
15
+	"time"
16
+)
17
+
18
+func TestInotifyCloseRightAway(t *testing.T) {
19
+	w, err := NewWatcher()
20
+	if err != nil {
21
+		t.Fatalf("Failed to create watcher")
22
+	}
23
+
24
+	// Close immediately; it won't even reach the first unix.Read.
25
+	w.Close()
26
+
27
+	// Wait for the close to complete.
28
+	<-time.After(50 * time.Millisecond)
29
+	isWatcherReallyClosed(t, w)
30
+}
31
+
32
+func TestInotifyCloseSlightlyLater(t *testing.T) {
33
+	w, err := NewWatcher()
34
+	if err != nil {
35
+		t.Fatalf("Failed to create watcher")
36
+	}
37
+
38
+	// Wait until readEvents has reached unix.Read, and Close.
39
+	<-time.After(50 * time.Millisecond)
40
+	w.Close()
41
+
42
+	// Wait for the close to complete.
43
+	<-time.After(50 * time.Millisecond)
44
+	isWatcherReallyClosed(t, w)
45
+}
46
+
47
+func TestInotifyCloseSlightlyLaterWithWatch(t *testing.T) {
48
+	testDir := tempMkdir(t)
49
+	defer os.RemoveAll(testDir)
50
+
51
+	w, err := NewWatcher()
52
+	if err != nil {
53
+		t.Fatalf("Failed to create watcher")
54
+	}
55
+	w.Add(testDir)
56
+
57
+	// Wait until readEvents has reached unix.Read, and Close.
58
+	<-time.After(50 * time.Millisecond)
59
+	w.Close()
60
+
61
+	// Wait for the close to complete.
62
+	<-time.After(50 * time.Millisecond)
63
+	isWatcherReallyClosed(t, w)
64
+}
65
+
66
+func TestInotifyCloseAfterRead(t *testing.T) {
67
+	testDir := tempMkdir(t)
68
+	defer os.RemoveAll(testDir)
69
+
70
+	w, err := NewWatcher()
71
+	if err != nil {
72
+		t.Fatalf("Failed to create watcher")
73
+	}
74
+
75
+	err = w.Add(testDir)
76
+	if err != nil {
77
+		t.Fatalf("Failed to add .")
78
+	}
79
+
80
+	// Generate an event.
81
+	os.Create(filepath.Join(testDir, "somethingSOMETHINGsomethingSOMETHING"))
82
+
83
+	// Wait for readEvents to read the event, then close the watcher.
84
+	<-time.After(50 * time.Millisecond)
85
+	w.Close()
86
+
87
+	// Wait for the close to complete.
88
+	<-time.After(50 * time.Millisecond)
89
+	isWatcherReallyClosed(t, w)
90
+}
91
+
92
+func isWatcherReallyClosed(t *testing.T, w *Watcher) {
93
+	select {
94
+	case err, ok := <-w.Errors:
95
+		if ok {
96
+			t.Fatalf("w.Errors is not closed; readEvents is still alive after closing (error: %v)", err)
97
+		}
98
+	default:
99
+		t.Fatalf("w.Errors would have blocked; readEvents is still alive!")
100
+	}
101
+
102
+	select {
103
+	case _, ok := <-w.Events:
104
+		if ok {
105
+			t.Fatalf("w.Events is not closed; readEvents is still alive after closing")
106
+		}
107
+	default:
108
+		t.Fatalf("w.Events would have blocked; readEvents is still alive!")
109
+	}
110
+}
111
+
112
+func TestInotifyCloseCreate(t *testing.T) {
113
+	testDir := tempMkdir(t)
114
+	defer os.RemoveAll(testDir)
115
+
116
+	w, err := NewWatcher()
117
+	if err != nil {
118
+		t.Fatalf("Failed to create watcher: %v", err)
119
+	}
120
+	defer w.Close()
121
+
122
+	err = w.Add(testDir)
123
+	if err != nil {
124
+		t.Fatalf("Failed to add testDir: %v", err)
125
+	}
126
+	h, err := os.Create(filepath.Join(testDir, "testfile"))
127
+	if err != nil {
128
+		t.Fatalf("Failed to create file in testdir: %v", err)
129
+	}
130
+	h.Close()
131
+	select {
132
+	case _ = <-w.Events:
133
+	case err := <-w.Errors:
134
+		t.Fatalf("Error from watcher: %v", err)
135
+	case <-time.After(50 * time.Millisecond):
136
+		t.Fatalf("Took too long to wait for event")
137
+	}
138
+
139
+	// At this point, we've received one event, so the goroutine is ready.
140
+	// It's also blocking on unix.Read.
141
+	// Now we try to swap the file descriptor under its nose.
142
+	w.Close()
143
+	w, err = NewWatcher()
144
+	defer w.Close()
145
+	if err != nil {
146
+		t.Fatalf("Failed to create second watcher: %v", err)
147
+	}
148
+
149
+	<-time.After(50 * time.Millisecond)
150
+	err = w.Add(testDir)
151
+	if err != nil {
152
+		t.Fatalf("Error adding testDir again: %v", err)
153
+	}
154
+}
155
+
156
+// This test verifies the watcher can keep up with file creations/deletions
157
+// when under load.
158
+func TestInotifyStress(t *testing.T) {
159
+	maxNumToCreate := 1000
160
+
161
+	testDir := tempMkdir(t)
162
+	defer os.RemoveAll(testDir)
163
+	testFilePrefix := filepath.Join(testDir, "testfile")
164
+
165
+	w, err := NewWatcher()
166
+	if err != nil {
167
+		t.Fatalf("Failed to create watcher: %v", err)
168
+	}
169
+	defer w.Close()
170
+
171
+	err = w.Add(testDir)
172
+	if err != nil {
173
+		t.Fatalf("Failed to add testDir: %v", err)
174
+	}
175
+
176
+	doneChan := make(chan struct{})
177
+	// The buffer ensures that the file generation goroutine is never blocked.
178
+	errChan := make(chan error, 2*maxNumToCreate)
179
+
180
+	go func() {
181
+		for i := 0; i < maxNumToCreate; i++ {
182
+			testFile := fmt.Sprintf("%s%d", testFilePrefix, i)
183
+
184
+			handle, err := os.Create(testFile)
185
+			if err != nil {
186
+				errChan <- fmt.Errorf("Create failed: %v", err)
187
+				continue
188
+			}
189
+
190
+			err = handle.Close()
191
+			if err != nil {
192
+				errChan <- fmt.Errorf("Close failed: %v", err)
193
+				continue
194
+			}
195
+		}
196
+
197
+		// If we delete a newly created file too quickly, inotify will skip the
198
+		// create event and only send the delete event.
199
+		time.Sleep(100 * time.Millisecond)
200
+
201
+		for i := 0; i < maxNumToCreate; i++ {
202
+			testFile := fmt.Sprintf("%s%d", testFilePrefix, i)
203
+			err = os.Remove(testFile)
204
+			if err != nil {
205
+				errChan <- fmt.Errorf("Remove failed: %v", err)
206
+			}
207
+		}
208
+
209
+		close(doneChan)
210
+	}()
211
+
212
+	creates := 0
213
+	removes := 0
214
+
215
+	finished := false
216
+	after := time.After(10 * time.Second)
217
+	for !finished {
218
+		select {
219
+		case <-after:
220
+			t.Fatalf("Not done")
221
+		case <-doneChan:
222
+			finished = true
223
+		case err := <-errChan:
224
+			t.Fatalf("Got an error from file creator goroutine: %v", err)
225
+		case err := <-w.Errors:
226
+			t.Fatalf("Got an error from watcher: %v", err)
227
+		case evt := <-w.Events:
228
+			if !strings.HasPrefix(evt.Name, testFilePrefix) {
229
+				t.Fatalf("Got an event for an unknown file: %s", evt.Name)
230
+			}
231
+			if evt.Op == Create {
232
+				creates++
233
+			}
234
+			if evt.Op == Remove {
235
+				removes++
236
+			}
237
+		}
238
+	}
239
+
240
+	// Drain remaining events from channels
241
+	count := 0
242
+	for count < 10 {
243
+		select {
244
+		case err := <-errChan:
245
+			t.Fatalf("Got an error from file creator goroutine: %v", err)
246
+		case err := <-w.Errors:
247
+			t.Fatalf("Got an error from watcher: %v", err)
248
+		case evt := <-w.Events:
249
+			if !strings.HasPrefix(evt.Name, testFilePrefix) {
250
+				t.Fatalf("Got an event for an unknown file: %s", evt.Name)
251
+			}
252
+			if evt.Op == Create {
253
+				creates++
254
+			}
255
+			if evt.Op == Remove {
256
+				removes++
257
+			}
258
+			count = 0
259
+		default:
260
+			count++
261
+			// Give the watcher chances to fill the channels.
262
+			time.Sleep(time.Millisecond)
263
+		}
264
+	}
265
+
266
+	if creates-removes > 1 || creates-removes < -1 {
267
+		t.Fatalf("Creates and removes should not be off by more than one: %d creates, %d removes", creates, removes)
268
+	}
269
+	if creates < 50 {
270
+		t.Fatalf("Expected at least 50 creates, got %d", creates)
271
+	}
272
+}
273
+
274
+func TestInotifyRemoveTwice(t *testing.T) {
275
+	testDir := tempMkdir(t)
276
+	defer os.RemoveAll(testDir)
277
+	testFile := filepath.Join(testDir, "testfile")
278
+
279
+	handle, err := os.Create(testFile)
280
+	if err != nil {
281
+		t.Fatalf("Create failed: %v", err)
282
+	}
283
+	handle.Close()
284
+
285
+	w, err := NewWatcher()
286
+	if err != nil {
287
+		t.Fatalf("Failed to create watcher: %v", err)
288
+	}
289
+	defer w.Close()
290
+
291
+	err = w.Add(testFile)
292
+	if err != nil {
293
+		t.Fatalf("Failed to add testFile: %v", err)
294
+	}
295
+
296
+	err = w.Remove(testFile)
297
+	if err != nil {
298
+		t.Fatalf("wanted successful remove but got:", err)
299
+	}
300
+
301
+	err = w.Remove(testFile)
302
+	if err == nil {
303
+		t.Fatalf("no error on removing invalid file")
304
+	}
305
+
306
+	w.mu.Lock()
307
+	defer w.mu.Unlock()
308
+	if len(w.watches) != 0 {
309
+		t.Fatalf("Expected watches len is 0, but got: %d, %v", len(w.watches), w.watches)
310
+	}
311
+	if len(w.paths) != 0 {
312
+		t.Fatalf("Expected paths len is 0, but got: %d, %v", len(w.paths), w.paths)
313
+	}
314
+}
315
+
316
+func TestInotifyInnerMapLength(t *testing.T) {
317
+	testDir := tempMkdir(t)
318
+	defer os.RemoveAll(testDir)
319
+	testFile := filepath.Join(testDir, "testfile")
320
+
321
+	handle, err := os.Create(testFile)
322
+	if err != nil {
323
+		t.Fatalf("Create failed: %v", err)
324
+	}
325
+	handle.Close()
326
+
327
+	w, err := NewWatcher()
328
+	if err != nil {
329
+		t.Fatalf("Failed to create watcher: %v", err)
330
+	}
331
+	defer w.Close()
332
+
333
+	err = w.Add(testFile)
334
+	if err != nil {
335
+		t.Fatalf("Failed to add testFile: %v", err)
336
+	}
337
+	go func() {
338
+		for err := range w.Errors {
339
+			t.Fatalf("error received: %s", err)
340
+		}
341
+	}()
342
+
343
+	err = os.Remove(testFile)
344
+	if err != nil {
345
+		t.Fatalf("Failed to remove testFile: %v", err)
346
+	}
347
+	_ = <-w.Events                      // consume Remove event
348
+	<-time.After(50 * time.Millisecond) // wait IN_IGNORE propagated
349
+
350
+	w.mu.Lock()
351
+	defer w.mu.Unlock()
352
+	if len(w.watches) != 0 {
353
+		t.Fatalf("Expected watches len is 0, but got: %d, %v", len(w.watches), w.watches)
354
+	}
355
+	if len(w.paths) != 0 {
356
+		t.Fatalf("Expected paths len is 0, but got: %d, %v", len(w.paths), w.paths)
357
+	}
358
+}
359
+
360
+func TestInotifyOverflow(t *testing.T) {
361
+	// We need to generate many more events than the
362
+	// fs.inotify.max_queued_events sysctl setting.
363
+	// We use multiple goroutines (one per directory)
364
+	// to speed up file creation.
365
+	numDirs := 128
366
+	numFiles := 1024
367
+
368
+	testDir := tempMkdir(t)
369
+	defer os.RemoveAll(testDir)
370
+
371
+	w, err := NewWatcher()
372
+	if err != nil {
373
+		t.Fatalf("Failed to create watcher: %v", err)
374
+	}
375
+	defer w.Close()
376
+
377
+	for dn := 0; dn < numDirs; dn++ {
378
+		testSubdir := fmt.Sprintf("%s/%d", testDir, dn)
379
+
380
+		err := os.Mkdir(testSubdir, 0777)
381
+		if err != nil {
382
+			t.Fatalf("Cannot create subdir: %v", err)
383
+		}
384
+
385
+		err = w.Add(testSubdir)
386
+		if err != nil {
387
+			t.Fatalf("Failed to add subdir: %v", err)
388
+		}
389
+	}
390
+
391
+	errChan := make(chan error, numDirs*numFiles)
392
+
393
+	for dn := 0; dn < numDirs; dn++ {
394
+		testSubdir := fmt.Sprintf("%s/%d", testDir, dn)
395
+
396
+		go func() {
397
+			for fn := 0; fn < numFiles; fn++ {
398
+				testFile := fmt.Sprintf("%s/%d", testSubdir, fn)
399
+
400
+				handle, err := os.Create(testFile)
401
+				if err != nil {
402
+					errChan <- fmt.Errorf("Create failed: %v", err)
403
+					continue
404
+				}
405
+
406
+				err = handle.Close()
407
+				if err != nil {
408
+					errChan <- fmt.Errorf("Close failed: %v", err)
409
+					continue
410
+				}
411
+			}
412
+		}()
413
+	}
414
+
415
+	creates := 0
416
+	overflows := 0
417
+
418
+	after := time.After(10 * time.Second)
419
+	for overflows == 0 && creates < numDirs*numFiles {
420
+		select {
421
+		case <-after:
422
+			t.Fatalf("Not done")
423
+		case err := <-errChan:
424
+			t.Fatalf("Got an error from file creator goroutine: %v", err)
425
+		case err := <-w.Errors:
426
+			if err == ErrEventOverflow {
427
+				overflows++
428
+			} else {
429
+				t.Fatalf("Got an error from watcher: %v", err)
430
+			}
431
+		case evt := <-w.Events:
432
+			if !strings.HasPrefix(evt.Name, testDir) {
433
+				t.Fatalf("Got an event for an unknown file: %s", evt.Name)
434
+			}
435
+			if evt.Op == Create {
436
+				creates++
437
+			}
438
+		}
439
+	}
440
+
441
+	if creates == numDirs*numFiles {
442
+		t.Fatalf("Could not trigger overflow")
443
+	}
444
+
445
+	if overflows == 0 {
446
+		t.Fatalf("No overflow and not enough creates (expected %d, got %d)",
447
+			numDirs*numFiles, creates)
448
+	}
449
+}

+ 147
- 0
vendor/github.com/fsnotify/fsnotify/integration_darwin_test.go View File

@@ -0,0 +1,147 @@
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 fsnotify
6
+
7
+import (
8
+	"os"
9
+	"path/filepath"
10
+	"testing"
11
+	"time"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+// testExchangedataForWatcher tests the watcher with the exchangedata operation on macOS.
17
+//
18
+// This is widely used for atomic saves on macOS, e.g. TextMate and in Apple's NSDocument.
19
+//
20
+// See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/exchangedata.2.html
21
+// Also see: https://github.com/textmate/textmate/blob/cd016be29489eba5f3c09b7b70b06da134dda550/Frameworks/io/src/swap_file_data.cc#L20
22
+func testExchangedataForWatcher(t *testing.T, watchDir bool) {
23
+	// Create directory to watch
24
+	testDir1 := tempMkdir(t)
25
+
26
+	// For the intermediate file
27
+	testDir2 := tempMkdir(t)
28
+
29
+	defer os.RemoveAll(testDir1)
30
+	defer os.RemoveAll(testDir2)
31
+
32
+	resolvedFilename := "TestFsnotifyEvents.file"
33
+
34
+	// TextMate does:
35
+	//
36
+	// 1. exchangedata (intermediate, resolved)
37
+	// 2. unlink intermediate
38
+	//
39
+	// Let's try to simulate that:
40
+	resolved := filepath.Join(testDir1, resolvedFilename)
41
+	intermediate := filepath.Join(testDir2, resolvedFilename+"~")
42
+
43
+	// Make sure we create the file before we start watching
44
+	createAndSyncFile(t, resolved)
45
+
46
+	watcher := newWatcher(t)
47
+
48
+	// Test both variants in isolation
49
+	if watchDir {
50
+		addWatch(t, watcher, testDir1)
51
+	} else {
52
+		addWatch(t, watcher, resolved)
53
+	}
54
+
55
+	// Receive errors on the error channel on a separate goroutine
56
+	go func() {
57
+		for err := range watcher.Errors {
58
+			t.Fatalf("error received: %s", err)
59
+		}
60
+	}()
61
+
62
+	// Receive events on the event channel on a separate goroutine
63
+	eventstream := watcher.Events
64
+	var removeReceived counter
65
+	var createReceived counter
66
+
67
+	done := make(chan bool)
68
+
69
+	go func() {
70
+		for event := range eventstream {
71
+			// Only count relevant events
72
+			if event.Name == filepath.Clean(resolved) {
73
+				if event.Op&Remove == Remove {
74
+					removeReceived.increment()
75
+				}
76
+				if event.Op&Create == Create {
77
+					createReceived.increment()
78
+				}
79
+			}
80
+			t.Logf("event received: %s", event)
81
+		}
82
+		done <- true
83
+	}()
84
+
85
+	// Repeat to make sure the watched file/directory "survives" the REMOVE/CREATE loop.
86
+	for i := 1; i <= 3; i++ {
87
+		// The intermediate file is created in a folder outside the watcher
88
+		createAndSyncFile(t, intermediate)
89
+
90
+		// 1. Swap
91
+		if err := unix.Exchangedata(intermediate, resolved, 0); err != nil {
92
+			t.Fatalf("[%d] exchangedata failed: %s", i, err)
93
+		}
94
+
95
+		time.Sleep(50 * time.Millisecond)
96
+
97
+		// 2. Delete the intermediate file
98
+		err := os.Remove(intermediate)
99
+
100
+		if err != nil {
101
+			t.Fatalf("[%d] remove %s failed: %s", i, intermediate, err)
102
+		}
103
+
104
+		time.Sleep(50 * time.Millisecond)
105
+
106
+	}
107
+
108
+	// We expect this event to be received almost immediately, but let's wait 500 ms to be sure
109
+	time.Sleep(500 * time.Millisecond)
110
+
111
+	// The events will be (CHMOD + REMOVE + CREATE) X 2. Let's focus on the last two:
112
+	if removeReceived.value() < 3 {
113
+		t.Fatal("fsnotify remove events have not been received after 500 ms")
114
+	}
115
+
116
+	if createReceived.value() < 3 {
117
+		t.Fatal("fsnotify create events have not been received after 500 ms")
118
+	}
119
+
120
+	watcher.Close()
121
+	t.Log("waiting for the event channel to become closed...")
122
+	select {
123
+	case <-done:
124
+		t.Log("event channel closed")
125
+	case <-time.After(2 * time.Second):
126
+		t.Fatal("event stream was not closed after 2 seconds")
127
+	}
128
+}
129
+
130
+// TestExchangedataInWatchedDir test exchangedata operation on file in watched dir.
131
+func TestExchangedataInWatchedDir(t *testing.T) {
132
+	testExchangedataForWatcher(t, true)
133
+}
134
+
135
+// TestExchangedataInWatchedDir test exchangedata operation on watched file.
136
+func TestExchangedataInWatchedFile(t *testing.T) {
137
+	testExchangedataForWatcher(t, false)
138
+}
139
+
140
+func createAndSyncFile(t *testing.T, filepath string) {
141
+	f1, err := os.OpenFile(filepath, os.O_WRONLY|os.O_CREATE, 0666)
142
+	if err != nil {
143
+		t.Fatalf("creating %s failed: %s", filepath, err)
144
+	}
145
+	f1.Sync()
146
+	f1.Close()
147
+}

+ 1237
- 0
vendor/github.com/fsnotify/fsnotify/integration_test.go
File diff suppressed because it is too large
View File


+ 503
- 0
vendor/github.com/fsnotify/fsnotify/kqueue.go View File

@@ -0,0 +1,503 @@
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 freebsd openbsd netbsd dragonfly darwin
6
+
7
+package fsnotify
8
+
9
+import (
10
+	"errors"
11
+	"fmt"
12
+	"io/ioutil"
13
+	"os"
14
+	"path/filepath"
15
+	"sync"
16
+	"time"
17
+
18
+	"golang.org/x/sys/unix"
19
+)
20
+
21
+// Watcher watches a set of files, delivering events to a channel.
22
+type Watcher struct {
23
+	Events chan Event
24
+	Errors chan error
25
+	done   chan bool // Channel for sending a "quit message" to the reader goroutine
26
+
27
+	kq int // File descriptor (as returned by the kqueue() syscall).
28
+
29
+	mu              sync.Mutex        // Protects access to watcher data
30
+	watches         map[string]int    // Map of watched file descriptors (key: path).
31
+	externalWatches map[string]bool   // Map of watches added by user of the library.
32
+	dirFlags        map[string]uint32 // Map of watched directories to fflags used in kqueue.
33
+	paths           map[int]pathInfo  // Map file descriptors to path names for processing kqueue events.
34
+	fileExists      map[string]bool   // Keep track of if we know this file exists (to stop duplicate create events).
35
+	isClosed        bool              // Set to true when Close() is first called
36
+}
37
+
38
+type pathInfo struct {
39
+	name  string
40
+	isDir bool
41
+}
42
+
43
+// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
44
+func NewWatcher() (*Watcher, error) {
45
+	kq, err := kqueue()
46
+	if err != nil {
47
+		return nil, err
48
+	}
49
+
50
+	w := &Watcher{
51
+		kq:              kq,
52
+		watches:         make(map[string]int),
53
+		dirFlags:        make(map[string]uint32),
54
+		paths:           make(map[int]pathInfo),
55
+		fileExists:      make(map[string]bool),
56
+		externalWatches: make(map[string]bool),
57
+		Events:          make(chan Event),
58
+		Errors:          make(chan error),
59
+		done:            make(chan bool),
60
+	}
61
+
62
+	go w.readEvents()
63
+	return w, nil
64
+}
65
+
66
+// Close removes all watches and closes the events channel.
67
+func (w *Watcher) Close() error {
68
+	w.mu.Lock()
69
+	if w.isClosed {
70
+		w.mu.Unlock()
71
+		return nil
72
+	}
73
+	w.isClosed = true
74
+	w.mu.Unlock()
75
+
76
+	// copy paths to remove while locked
77
+	w.mu.Lock()
78
+	var pathsToRemove = make([]string, 0, len(w.watches))
79
+	for name := range w.watches {
80
+		pathsToRemove = append(pathsToRemove, name)
81
+	}
82
+	w.mu.Unlock()
83
+	// unlock before calling Remove, which also locks
84
+
85
+	var err error
86
+	for _, name := range pathsToRemove {
87
+		if e := w.Remove(name); e != nil && err == nil {
88
+			err = e
89
+		}
90
+	}
91
+
92
+	// Send "quit" message to the reader goroutine:
93
+	w.done <- true
94
+
95
+	return nil
96
+}
97
+
98
+// Add starts watching the named file or directory (non-recursively).
99
+func (w *Watcher) Add(name string) error {
100
+	w.mu.Lock()
101
+	w.externalWatches[name] = true
102
+	w.mu.Unlock()
103
+	_, err := w.addWatch(name, noteAllEvents)
104
+	return err
105
+}
106
+
107
+// Remove stops watching the the named file or directory (non-recursively).
108
+func (w *Watcher) Remove(name string) error {
109
+	name = filepath.Clean(name)
110
+	w.mu.Lock()
111
+	watchfd, ok := w.watches[name]
112
+	w.mu.Unlock()
113
+	if !ok {
114
+		return fmt.Errorf("can't remove non-existent kevent watch for: %s", name)
115
+	}
116
+
117
+	const registerRemove = unix.EV_DELETE
118
+	if err := register(w.kq, []int{watchfd}, registerRemove, 0); err != nil {
119
+		return err
120
+	}
121
+
122
+	unix.Close(watchfd)
123
+
124
+	w.mu.Lock()
125
+	isDir := w.paths[watchfd].isDir
126
+	delete(w.watches, name)
127
+	delete(w.paths, watchfd)
128
+	delete(w.dirFlags, name)
129
+	w.mu.Unlock()
130
+
131
+	// Find all watched paths that are in this directory that are not external.
132
+	if isDir {
133
+		var pathsToRemove []string
134
+		w.mu.Lock()
135
+		for _, path := range w.paths {
136
+			wdir, _ := filepath.Split(path.name)
137
+			if filepath.Clean(wdir) == name {
138
+				if !w.externalWatches[path.name] {
139
+					pathsToRemove = append(pathsToRemove, path.name)
140
+				}
141
+			}
142
+		}
143
+		w.mu.Unlock()
144
+		for _, name := range pathsToRemove {
145
+			// Since these are internal, not much sense in propagating error
146
+			// to the user, as that will just confuse them with an error about
147
+			// a path they did not explicitly watch themselves.
148
+			w.Remove(name)
149
+		}
150
+	}
151
+
152
+	return nil
153
+}
154
+
155
+// Watch all events (except NOTE_EXTEND, NOTE_LINK, NOTE_REVOKE)
156
+const noteAllEvents = unix.NOTE_DELETE | unix.NOTE_WRITE | unix.NOTE_ATTRIB | unix.NOTE_RENAME
157
+
158
+// keventWaitTime to block on each read from kevent
159
+var keventWaitTime = durationToTimespec(100 * time.Millisecond)
160
+
161
+// addWatch adds name to the watched file set.
162
+// The flags are interpreted as described in kevent(2).
163
+// Returns the real path to the file which was added, if any, which may be different from the one passed in the case of symlinks.
164
+func (w *Watcher) addWatch(name string, flags uint32) (string, error) {
165
+	var isDir bool
166
+	// Make ./name and name equivalent
167
+	name = filepath.Clean(name)
168
+
169
+	w.mu.Lock()
170
+	if w.isClosed {
171
+		w.mu.Unlock()
172
+		return "", errors.New("kevent instance already closed")
173
+	}
174
+	watchfd, alreadyWatching := w.watches[name]
175
+	// We already have a watch, but we can still override flags.
176
+	if alreadyWatching {
177
+		isDir = w.paths[watchfd].isDir
178
+	}
179
+	w.mu.Unlock()
180
+
181
+	if !alreadyWatching {
182
+		fi, err := os.Lstat(name)
183
+		if err != nil {
184
+			return "", err
185
+		}
186
+
187
+		// Don't watch sockets.
188
+		if fi.Mode()&os.ModeSocket == os.ModeSocket {
189
+			return "", nil
190
+		}
191
+
192
+		// Don't watch named pipes.
193
+		if fi.Mode()&os.ModeNamedPipe == os.ModeNamedPipe {
194
+			return "", nil
195
+		}
196
+
197
+		// Follow Symlinks
198
+		// Unfortunately, Linux can add bogus symlinks to watch list without
199
+		// issue, and Windows can't do symlinks period (AFAIK). To  maintain
200
+		// consistency, we will act like everything is fine. There will simply
201
+		// be no file events for broken symlinks.
202
+		// Hence the returns of nil on errors.
203
+		if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
204
+			name, err = filepath.EvalSymlinks(name)
205
+			if err != nil {
206
+				return "", nil
207
+			}
208
+
209
+			w.mu.Lock()
210
+			_, alreadyWatching = w.watches[name]
211
+			w.mu.Unlock()
212
+
213
+			if alreadyWatching {
214
+				return name, nil
215
+			}
216
+
217
+			fi, err = os.Lstat(name)
218
+			if err != nil {
219
+				return "", nil
220
+			}
221
+		}
222
+
223
+		watchfd, err = unix.Open(name, openMode, 0700)
224
+		if watchfd == -1 {
225
+			return "", err
226
+		}
227
+
228
+		isDir = fi.IsDir()
229
+	}
230
+
231
+	const registerAdd = unix.EV_ADD | unix.EV_CLEAR | unix.EV_ENABLE
232
+	if err := register(w.kq, []int{watchfd}, registerAdd, flags); err != nil {
233
+		unix.Close(watchfd)
234
+		return "", err
235
+	}
236
+
237
+	if !alreadyWatching {
238
+		w.mu.Lock()
239
+		w.watches[name] = watchfd
240
+		w.paths[watchfd] = pathInfo{name: name, isDir: isDir}
241
+		w.mu.Unlock()
242
+	}
243
+
244
+	if isDir {
245
+		// Watch the directory if it has not been watched before,
246
+		// or if it was watched before, but perhaps only a NOTE_DELETE (watchDirectoryFiles)
247
+		w.mu.Lock()
248
+
249
+		watchDir := (flags&unix.NOTE_WRITE) == unix.NOTE_WRITE &&
250
+			(!alreadyWatching || (w.dirFlags[name]&unix.NOTE_WRITE) != unix.NOTE_WRITE)
251
+		// Store flags so this watch can be updated later
252
+		w.dirFlags[name] = flags
253
+		w.mu.Unlock()
254
+
255
+		if watchDir {
256
+			if err := w.watchDirectoryFiles(name); err != nil {
257
+				return "", err
258
+			}
259
+		}
260
+	}
261
+	return name, nil
262
+}
263
+
264
+// readEvents reads from kqueue and converts the received kevents into
265
+// Event values that it sends down the Events channel.
266
+func (w *Watcher) readEvents() {
267
+	eventBuffer := make([]unix.Kevent_t, 10)
268
+
269
+	for {
270
+		// See if there is a message on the "done" channel
271
+		select {
272
+		case <-w.done:
273
+			err := unix.Close(w.kq)
274
+			if err != nil {
275
+				w.Errors <- err
276
+			}
277
+			close(w.Events)
278
+			close(w.Errors)
279
+			return
280
+		default:
281
+		}
282
+
283
+		// Get new events
284
+		kevents, err := read(w.kq, eventBuffer, &keventWaitTime)
285
+		// EINTR is okay, the syscall was interrupted before timeout expired.
286
+		if err != nil && err != unix.EINTR {
287
+			w.Errors <- err
288
+			continue
289
+		}
290
+
291
+		// Flush the events we received to the Events channel
292
+		for len(kevents) > 0 {
293
+			kevent := &kevents[0]
294
+			watchfd := int(kevent.Ident)
295
+			mask := uint32(kevent.Fflags)
296
+			w.mu.Lock()
297
+			path := w.paths[watchfd]
298
+			w.mu.Unlock()
299
+			event := newEvent(path.name, mask)
300
+
301
+			if path.isDir && !(event.Op&Remove == Remove) {
302
+				// Double check to make sure the directory exists. This can happen when
303
+				// we do a rm -fr on a recursively watched folders and we receive a
304
+				// modification event first but the folder has been deleted and later
305
+				// receive the delete event
306
+				if _, err := os.Lstat(event.Name); os.IsNotExist(err) {
307
+					// mark is as delete event
308
+					event.Op |= Remove
309
+				}
310
+			}
311
+
312
+			if event.Op&Rename == Rename || event.Op&Remove == Remove {
313
+				w.Remove(event.Name)
314
+				w.mu.Lock()
315
+				delete(w.fileExists, event.Name)
316
+				w.mu.Unlock()
317
+			}
318
+
319
+			if path.isDir && event.Op&Write == Write && !(event.Op&Remove == Remove) {
320
+				w.sendDirectoryChangeEvents(event.Name)
321
+			} else {
322
+				// Send the event on the Events channel
323
+				w.Events <- event
324
+			}
325
+
326
+			if event.Op&Remove == Remove {
327
+				// Look for a file that may have overwritten this.
328
+				// For example, mv f1 f2 will delete f2, then create f2.
329
+				if path.isDir {
330
+					fileDir := filepath.Clean(event.Name)
331
+					w.mu.Lock()
332
+					_, found := w.watches[fileDir]
333
+					w.mu.Unlock()
334
+					if found {
335
+						// make sure the directory exists before we watch for changes. When we
336
+						// do a recursive watch and perform rm -fr, the parent directory might
337
+						// have gone missing, ignore the missing directory and let the
338
+						// upcoming delete event remove the watch from the parent directory.
339
+						if _, err := os.Lstat(fileDir); err == nil {
340
+							w.sendDirectoryChangeEvents(fileDir)
341
+						}
342
+					}
343
+				} else {
344
+					filePath := filepath.Clean(event.Name)
345
+					if fileInfo, err := os.Lstat(filePath); err == nil {
346
+						w.sendFileCreatedEventIfNew(filePath, fileInfo)
347
+					}
348
+				}
349
+			}
350
+
351
+			// Move to next event
352
+			kevents = kevents[1:]
353
+		}
354
+	}
355
+}
356
+
357
+// newEvent returns an platform-independent Event based on kqueue Fflags.
358
+func newEvent(name string, mask uint32) Event {
359
+	e := Event{Name: name}
360
+	if mask&unix.NOTE_DELETE == unix.NOTE_DELETE {
361
+		e.Op |= Remove
362
+	}
363
+	if mask&unix.NOTE_WRITE == unix.NOTE_WRITE {
364
+		e.Op |= Write
365
+	}
366
+	if mask&unix.NOTE_RENAME == unix.NOTE_RENAME {
367
+		e.Op |= Rename
368
+	}
369
+	if mask&unix.NOTE_ATTRIB == unix.NOTE_ATTRIB {
370
+		e.Op |= Chmod
371
+	}
372
+	return e
373
+}
374
+
375
+func newCreateEvent(name string) Event {
376
+	return Event{Name: name, Op: Create}
377
+}
378
+
379
+// watchDirectoryFiles to mimic inotify when adding a watch on a directory
380
+func (w *Watcher) watchDirectoryFiles(dirPath string) error {
381
+	// Get all files
382
+	files, err := ioutil.ReadDir(dirPath)
383
+	if err != nil {
384
+		return err
385
+	}
386
+
387
+	for _, fileInfo := range files {
388
+		filePath := filepath.Join(dirPath, fileInfo.Name())
389
+		filePath, err = w.internalWatch(filePath, fileInfo)
390
+		if err != nil {
391
+			return err
392
+		}
393
+
394
+		w.mu.Lock()
395
+		w.fileExists[filePath] = true
396
+		w.mu.Unlock()
397
+	}
398
+
399
+	return nil
400
+}
401
+
402
+// sendDirectoryEvents searches the directory for newly created files
403
+// and sends them over the event channel. This functionality is to have
404
+// the BSD version of fsnotify match Linux inotify which provides a
405
+// create event for files created in a watched directory.
406
+func (w *Watcher) sendDirectoryChangeEvents(dirPath string) {
407
+	// Get all files
408
+	files, err := ioutil.ReadDir(dirPath)
409
+	if err != nil {
410
+		w.Errors <- err
411
+	}
412
+
413
+	// Search for new files
414
+	for _, fileInfo := range files {
415
+		filePath := filepath.Join(dirPath, fileInfo.Name())
416
+		err := w.sendFileCreatedEventIfNew(filePath, fileInfo)
417
+
418
+		if err != nil {
419
+			return
420
+		}
421
+	}
422
+}
423
+
424
+// sendFileCreatedEvent sends a create event if the file isn't already being tracked.
425
+func (w *Watcher) sendFileCreatedEventIfNew(filePath string, fileInfo os.FileInfo) (err error) {
426
+	w.mu.Lock()
427
+	_, doesExist := w.fileExists[filePath]
428
+	w.mu.Unlock()
429
+	if !doesExist {
430
+		// Send create event
431
+		w.Events <- newCreateEvent(filePath)
432
+	}
433
+
434
+	// like watchDirectoryFiles (but without doing another ReadDir)
435
+	filePath, err = w.internalWatch(filePath, fileInfo)
436
+	if err != nil {
437
+		return err
438
+	}
439
+
440
+	w.mu.Lock()
441
+	w.fileExists[filePath] = true
442
+	w.mu.Unlock()
443
+
444
+	return nil
445
+}
446
+
447
+func (w *Watcher) internalWatch(name string, fileInfo os.FileInfo) (string, error) {
448
+	if fileInfo.IsDir() {
449
+		// mimic Linux providing delete events for subdirectories
450
+		// but preserve the flags used if currently watching subdirectory
451
+		w.mu.Lock()
452
+		flags := w.dirFlags[name]
453
+		w.mu.Unlock()
454
+
455
+		flags |= unix.NOTE_DELETE | unix.NOTE_RENAME
456
+		return w.addWatch(name, flags)
457
+	}
458
+
459
+	// watch file to mimic Linux inotify
460
+	return w.addWatch(name, noteAllEvents)
461
+}
462
+
463
+// kqueue creates a new kernel event queue and returns a descriptor.
464
+func kqueue() (kq int, err error) {
465
+	kq, err = unix.Kqueue()
466
+	if kq == -1 {
467
+		return kq, err
468
+	}
469
+	return kq, nil
470
+}
471
+
472
+// register events with the queue
473
+func register(kq int, fds []int, flags int, fflags uint32) error {
474
+	changes := make([]unix.Kevent_t, len(fds))
475
+
476
+	for i, fd := range fds {
477
+		// SetKevent converts int to the platform-specific types:
478
+		unix.SetKevent(&changes[i], fd, unix.EVFILT_VNODE, flags)
479
+		changes[i].Fflags = fflags
480
+	}
481
+
482
+	// register the events
483
+	success, err := unix.Kevent(kq, changes, nil, nil)
484
+	if success == -1 {
485
+		return err
486
+	}
487
+	return nil
488
+}
489
+
490
+// read retrieves pending events, or waits until an event occurs.
491
+// A timeout of nil blocks indefinitely, while 0 polls the queue.
492
+func read(kq int, events []unix.Kevent_t, timeout *unix.Timespec) ([]unix.Kevent_t, error) {
493
+	n, err := unix.Kevent(kq, nil, events, timeout)
494
+	if err != nil {
495
+		return nil, err
496
+	}
497
+	return events[0:n], nil
498
+}
499
+
500
+// durationToTimespec prepares a timeout value
501
+func durationToTimespec(d time.Duration) unix.Timespec {
502
+	return unix.NsecToTimespec(d.Nanoseconds())
503
+}

+ 11
- 0
vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go View File

@@ -0,0 +1,11 @@
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 freebsd openbsd netbsd dragonfly
6
+
7
+package fsnotify
8
+
9
+import "golang.org/x/sys/unix"
10
+
11
+const openMode = unix.O_NONBLOCK | unix.O_RDONLY

+ 12
- 0
vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go View File

@@ -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
6
+
7
+package fsnotify
8
+
9
+import "golang.org/x/sys/unix"
10
+
11
+// note: this constant is not defined on BSD
12
+const openMode = unix.O_EVTONLY

+ 561
- 0
vendor/github.com/fsnotify/fsnotify/windows.go View File

@@ -0,0 +1,561 @@
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 fsnotify
8
+
9
+import (
10
+	"errors"
11
+	"fmt"
12
+	"os"
13
+	"path/filepath"
14
+	"runtime"
15
+	"sync"
16
+	"syscall"
17
+	"unsafe"
18
+)
19
+
20
+// Watcher watches a set of files, delivering events to a channel.
21
+type Watcher struct {
22
+	Events   chan Event
23
+	Errors   chan error
24
+	isClosed bool           // Set to true when Close() is first called
25
+	mu       sync.Mutex     // Map access
26
+	port     syscall.Handle // Handle to completion port
27
+	watches  watchMap       // Map of watches (key: i-number)
28
+	input    chan *input    // Inputs to the reader are sent on this channel
29
+	quit     chan chan<- error
30
+}
31
+
32
+// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
33
+func NewWatcher() (*Watcher, error) {
34
+	port, e := syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 0)
35
+	if e != nil {
36
+		return nil, os.NewSyscallError("CreateIoCompletionPort", e)
37
+	}
38
+	w := &Watcher{
39
+		port:    port,
40
+		watches: make(watchMap),
41
+		input:   make(chan *input, 1),
42
+		Events:  make(chan Event, 50),
43
+		Errors:  make(chan error),
44
+		quit:    make(chan chan<- error, 1),
45
+	}
46
+	go w.readEvents()
47
+	return w, nil
48
+}
49
+
50
+// Close removes all watches and closes the events channel.
51
+func (w *Watcher) Close() error {
52
+	if w.isClosed {
53
+		return nil
54
+	}
55
+	w.isClosed = true
56
+
57
+	// Send "quit" message to the reader goroutine
58
+	ch := make(chan error)
59
+	w.quit <- ch
60
+	if err := w.wakeupReader(); err != nil {
61
+		return err
62
+	}
63
+	return <-ch
64
+}
65
+
66
+// Add starts watching the named file or directory (non-recursively).
67
+func (w *Watcher) Add(name string) error {
68
+	if w.isClosed {
69
+		return errors.New("watcher already closed")
70
+	}
71
+	in := &input{
72
+		op:    opAddWatch,
73
+		path:  filepath.Clean(name),
74
+		flags: sysFSALLEVENTS,
75
+		reply: make(chan error),
76
+	}
77
+	w.input <- in
78
+	if err := w.wakeupReader(); err != nil {
79
+		return err
80
+	}
81
+	return <-in.reply
82
+}
83
+
84
+// Remove stops watching the the named file or directory (non-recursively).
85
+func (w *Watcher) Remove(name string) error {
86
+	in := &input{
87
+		op:    opRemoveWatch,
88
+		path:  filepath.Clean(name),
89
+		reply: make(chan error),
90
+	}
91
+	w.input <- in
92
+	if err := w.wakeupReader(); err != nil {
93
+		return err
94
+	}
95
+	return <-in.reply
96
+}
97
+
98
+const (
99
+	// Options for AddWatch
100
+	sysFSONESHOT = 0x80000000
101
+	sysFSONLYDIR = 0x1000000
102
+
103
+	// Events
104
+	sysFSACCESS     = 0x1
105
+	sysFSALLEVENTS  = 0xfff
106
+	sysFSATTRIB     = 0x4
107
+	sysFSCLOSE      = 0x18
108
+	sysFSCREATE     = 0x100
109
+	sysFSDELETE     = 0x200
110
+	sysFSDELETESELF = 0x400
111
+	sysFSMODIFY     = 0x2
112
+	sysFSMOVE       = 0xc0
113
+	sysFSMOVEDFROM  = 0x40
114
+	sysFSMOVEDTO    = 0x80
115
+	sysFSMOVESELF   = 0x800
116
+
117
+	// Special events
118
+	sysFSIGNORED   = 0x8000
119
+	sysFSQOVERFLOW = 0x4000
120
+)
121
+
122
+func newEvent(name string, mask uint32) Event {
123
+	e := Event{Name: name}
124
+	if mask&sysFSCREATE == sysFSCREATE || mask&sysFSMOVEDTO == sysFSMOVEDTO {
125
+		e.Op |= Create
126
+	}
127
+	if mask&sysFSDELETE == sysFSDELETE || mask&sysFSDELETESELF == sysFSDELETESELF {
128
+		e.Op |= Remove
129
+	}
130
+	if mask&sysFSMODIFY == sysFSMODIFY {
131
+		e.Op |= Write
132
+	}
133
+	if mask&sysFSMOVE == sysFSMOVE || mask&sysFSMOVESELF == sysFSMOVESELF || mask&sysFSMOVEDFROM == sysFSMOVEDFROM {
134
+		e.Op |= Rename
135
+	}
136
+	if mask&sysFSATTRIB == sysFSATTRIB {
137
+		e.Op |= Chmod
138
+	}
139
+	return e
140
+}
141
+
142
+const (
143
+	opAddWatch = iota
144
+	opRemoveWatch
145
+)
146
+
147
+const (
148
+	provisional uint64 = 1 << (32 + iota)
149
+)
150
+
151
+type input struct {
152
+	op    int
153
+	path  string
154
+	flags uint32
155
+	reply chan error
156
+}
157
+
158
+type inode struct {
159
+	handle syscall.Handle
160
+	volume uint32
161
+	index  uint64
162
+}
163
+
164
+type watch struct {
165
+	ov     syscall.Overlapped
166
+	ino    *inode            // i-number
167
+	path   string            // Directory path
168
+	mask   uint64            // Directory itself is being watched with these notify flags
169
+	names  map[string]uint64 // Map of names being watched and their notify flags
170
+	rename string            // Remembers the old name while renaming a file
171
+	buf    [4096]byte
172
+}
173
+
174
+type indexMap map[uint64]*watch
175
+type watchMap map[uint32]indexMap
176
+
177
+func (w *Watcher) wakeupReader() error {
178
+	e := syscall.PostQueuedCompletionStatus(w.port, 0, 0, nil)
179
+	if e != nil {
180
+		return os.NewSyscallError("PostQueuedCompletionStatus", e)
181
+	}
182
+	return nil
183
+}
184
+
185
+func getDir(pathname string) (dir string, err error) {
186
+	attr, e := syscall.GetFileAttributes(syscall.StringToUTF16Ptr(pathname))
187
+	if e != nil {
188
+		return "", os.NewSyscallError("GetFileAttributes", e)
189
+	}
190
+	if attr&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 {
191
+		dir = pathname
192
+	} else {
193
+		dir, _ = filepath.Split(pathname)
194
+		dir = filepath.Clean(dir)
195
+	}
196
+	return
197
+}
198
+
199
+func getIno(path string) (ino *inode, err error) {
200
+	h, e := syscall.CreateFile(syscall.StringToUTF16Ptr(path),
201
+		syscall.FILE_LIST_DIRECTORY,
202
+		syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
203
+		nil, syscall.OPEN_EXISTING,
204
+		syscall.FILE_FLAG_BACKUP_SEMANTICS|syscall.FILE_FLAG_OVERLAPPED, 0)
205
+	if e != nil {
206
+		return nil, os.NewSyscallError("CreateFile", e)
207
+	}
208
+	var fi syscall.ByHandleFileInformation
209
+	if e = syscall.GetFileInformationByHandle(h, &fi); e != nil {
210
+		syscall.CloseHandle(h)
211
+		return nil, os.NewSyscallError("GetFileInformationByHandle", e)
212
+	}
213
+	ino = &inode{
214
+		handle: h,
215
+		volume: fi.VolumeSerialNumber,
216
+		index:  uint64(fi.FileIndexHigh)<<32 | uint64(fi.FileIndexLow),
217
+	}
218
+	return ino, nil
219
+}
220
+
221
+// Must run within the I/O thread.
222
+func (m watchMap) get(ino *inode) *watch {
223
+	if i := m[ino.volume]; i != nil {
224
+		return i[ino.index]
225
+	}
226
+	return nil
227
+}
228
+
229
+// Must run within the I/O thread.
230
+func (m watchMap) set(ino *inode, watch *watch) {
231
+	i := m[ino.volume]
232
+	if i == nil {
233
+		i = make(indexMap)
234
+		m[ino.volume] = i
235
+	}
236
+	i[ino.index] = watch
237
+}
238
+
239
+// Must run within the I/O thread.
240
+func (w *Watcher) addWatch(pathname string, flags uint64) error {
241
+	dir, err := getDir(pathname)
242
+	if err != nil {
243
+		return err
244
+	}
245
+	if flags&sysFSONLYDIR != 0 && pathname != dir {
246
+		return nil
247
+	}
248
+	ino, err := getIno(dir)
249
+	if err != nil {
250
+		return err
251
+	}
252
+	w.mu.Lock()
253
+	watchEntry := w.watches.get(ino)
254
+	w.mu.Unlock()
255
+	if watchEntry == nil {
256
+		if _, e := syscall.CreateIoCompletionPort(ino.handle, w.port, 0, 0); e != nil {
257
+			syscall.CloseHandle(ino.handle)
258
+			return os.NewSyscallError("CreateIoCompletionPort", e)
259
+		}
260
+		watchEntry = &watch{
261
+			ino:   ino,
262
+			path:  dir,
263
+			names: make(map[string]uint64),
264
+		}
265
+		w.mu.Lock()
266
+		w.watches.set(ino, watchEntry)
267
+		w.mu.Unlock()
268
+		flags |= provisional
269
+	} else {
270
+		syscall.CloseHandle(ino.handle)
271
+	}
272
+	if pathname == dir {
273
+		watchEntry.mask |= flags
274
+	} else {
275
+		watchEntry.names[filepath.Base(pathname)] |= flags
276
+	}
277
+	if err = w.startRead(watchEntry); err != nil {
278
+		return err
279
+	}
280
+	if pathname == dir {
281
+		watchEntry.mask &= ^provisional
282
+	} else {
283
+		watchEntry.names[filepath.Base(pathname)] &= ^provisional
284
+	}
285
+	return nil
286
+}
287
+
288
+// Must run within the I/O thread.
289
+func (w *Watcher) remWatch(pathname string) error {
290
+	dir, err := getDir(pathname)
291
+	if err != nil {
292
+		return err
293
+	}
294
+	ino, err := getIno(dir)
295
+	if err != nil {
296
+		return err
297
+	}
298
+	w.mu.Lock()
299
+	watch := w.watches.get(ino)
300
+	w.mu.Unlock()
301
+	if watch == nil {
302
+		return fmt.Errorf("can't remove non-existent watch for: %s", pathname)
303
+	}
304
+	if pathname == dir {
305
+		w.sendEvent(watch.path, watch.mask&sysFSIGNORED)
306
+		watch.mask = 0
307
+	} else {
308
+		name := filepath.Base(pathname)
309
+		w.sendEvent(filepath.Join(watch.path, name), watch.names[name]&sysFSIGNORED)
310
+		delete(watch.names, name)
311
+	}
312
+	return w.startRead(watch)
313
+}
314
+
315
+// Must run within the I/O thread.
316
+func (w *Watcher) deleteWatch(watch *watch) {
317
+	for name, mask := range watch.names {
318
+		if mask&provisional == 0 {
319
+			w.sendEvent(filepath.Join(watch.path, name), mask&sysFSIGNORED)
320
+		}
321
+		delete(watch.names, name)
322
+	}
323
+	if watch.mask != 0 {
324
+		if watch.mask&provisional == 0 {
325
+			w.sendEvent(watch.path, watch.mask&sysFSIGNORED)
326
+		}
327
+		watch.mask = 0
328
+	}
329
+}
330
+
331
+// Must run within the I/O thread.
332
+func (w *Watcher) startRead(watch *watch) error {
333
+	if e := syscall.CancelIo(watch.ino.handle); e != nil {
334
+		w.Errors <- os.NewSyscallError("CancelIo", e)
335
+		w.deleteWatch(watch)
336
+	}
337
+	mask := toWindowsFlags(watch.mask)
338
+	for _, m := range watch.names {
339
+		mask |= toWindowsFlags(m)
340
+	}
341
+	if mask == 0 {
342
+		if e := syscall.CloseHandle(watch.ino.handle); e != nil {
343
+			w.Errors <- os.NewSyscallError("CloseHandle", e)
344
+		}
345
+		w.mu.Lock()
346
+		delete(w.watches[watch.ino.volume], watch.ino.index)
347
+		w.mu.Unlock()
348
+		return nil
349
+	}
350
+	e := syscall.ReadDirectoryChanges(watch.ino.handle, &watch.buf[0],
351
+		uint32(unsafe.Sizeof(watch.buf)), false, mask, nil, &watch.ov, 0)
352
+	if e != nil {
353
+		err := os.NewSyscallError("ReadDirectoryChanges", e)
354
+		if e == syscall.ERROR_ACCESS_DENIED && watch.mask&provisional == 0 {
355
+			// Watched directory was probably removed
356
+			if w.sendEvent(watch.path, watch.mask&sysFSDELETESELF) {
357
+				if watch.mask&sysFSONESHOT != 0 {
358
+					watch.mask = 0
359
+				}
360
+			}
361
+			err = nil
362
+		}
363
+		w.deleteWatch(watch)
364
+		w.startRead(watch)
365
+		return err
366
+	}
367
+	return nil
368
+}
369
+
370
+// readEvents reads from the I/O completion port, converts the
371
+// received events into Event objects and sends them via the Events channel.
372
+// Entry point to the I/O thread.
373
+func (w *Watcher) readEvents() {
374
+	var (
375
+		n, key uint32
376
+		ov     *syscall.Overlapped
377
+	)
378
+	runtime.LockOSThread()
379
+
380
+	for {
381
+		e := syscall.GetQueuedCompletionStatus(w.port, &n, &key, &ov, syscall.INFINITE)
382
+		watch := (*watch)(unsafe.Pointer(ov))
383
+
384
+		if watch == nil {
385
+			select {
386
+			case ch := <-w.quit:
387
+				w.mu.Lock()
388
+				var indexes []indexMap
389
+				for _, index := range w.watches {
390
+					indexes = append(indexes, index)
391
+				}
392
+				w.mu.Unlock()
393
+				for _, index := range indexes {
394
+					for _, watch := range index {
395
+						w.deleteWatch(watch)
396
+						w.startRead(watch)
397
+					}
398
+				}
399
+				var err error
400
+				if e := syscall.CloseHandle(w.port); e != nil {
401
+					err = os.NewSyscallError("CloseHandle", e)
402
+				}
403
+				close(w.Events)
404
+				close(w.Errors)
405
+				ch <- err
406
+				return
407
+			case in := <-w.input:
408
+				switch in.op {
409
+				case opAddWatch:
410
+					in.reply <- w.addWatch(in.path, uint64(in.flags))
411
+				case opRemoveWatch:
412
+					in.reply <- w.remWatch(in.path)
413
+				}
414
+			default:
415
+			}
416
+			continue
417
+		}
418
+
419
+		switch e {
420
+		case syscall.ERROR_MORE_DATA:
421
+			if watch == nil {
422
+				w.Errors <- errors.New("ERROR_MORE_DATA has unexpectedly null lpOverlapped buffer")
423
+			} else {
424
+				// The i/o succeeded but the buffer is full.
425
+				// In theory we should be building up a full packet.
426
+				// In practice we can get away with just carrying on.
427
+				n = uint32(unsafe.Sizeof(watch.buf))
428
+			}
429
+		case syscall.ERROR_ACCESS_DENIED:
430
+			// Watched directory was probably removed
431
+			w.sendEvent(watch.path, watch.mask&sysFSDELETESELF)
432
+			w.deleteWatch(watch)
433
+			w.startRead(watch)
434
+			continue
435
+		case syscall.ERROR_OPERATION_ABORTED:
436
+			// CancelIo was called on this handle
437
+			continue
438
+		default:
439
+			w.Errors <- os.NewSyscallError("GetQueuedCompletionPort", e)
440
+			continue
441
+		case nil:
442
+		}
443
+
444
+		var offset uint32
445
+		for {
446
+			if n == 0 {
447
+				w.Events <- newEvent("", sysFSQOVERFLOW)
448
+				w.Errors <- errors.New("short read in readEvents()")
449
+				break
450
+			}
451
+
452
+			// Point "raw" to the event in the buffer
453
+			raw := (*syscall.FileNotifyInformation)(unsafe.Pointer(&watch.buf[offset]))
454
+			buf := (*[syscall.MAX_PATH]uint16)(unsafe.Pointer(&raw.FileName))
455
+			name := syscall.UTF16ToString(buf[:raw.FileNameLength/2])
456
+			fullname := filepath.Join(watch.path, name)
457
+
458
+			var mask uint64
459
+			switch raw.Action {
460
+			case syscall.FILE_ACTION_REMOVED:
461
+				mask = sysFSDELETESELF
462
+			case syscall.FILE_ACTION_MODIFIED:
463
+				mask = sysFSMODIFY
464
+			case syscall.FILE_ACTION_RENAMED_OLD_NAME:
465
+				watch.rename = name
466
+			case syscall.FILE_ACTION_RENAMED_NEW_NAME:
467
+				if watch.names[watch.rename] != 0 {
468
+					watch.names[name] |= watch.names[watch.rename]
469
+					delete(watch.names, watch.rename)
470
+					mask = sysFSMOVESELF
471
+				}
472
+			}
473
+
474
+			sendNameEvent := func() {
475
+				if w.sendEvent(fullname, watch.names[name]&mask) {
476
+					if watch.names[name]&sysFSONESHOT != 0 {
477
+						delete(watch.names, name)
478
+					}
479
+				}
480
+			}
481
+			if raw.Action != syscall.FILE_ACTION_RENAMED_NEW_NAME {
482
+				sendNameEvent()
483
+			}
484
+			if raw.Action == syscall.FILE_ACTION_REMOVED {
485
+				w.sendEvent(fullname, watch.names[name]&sysFSIGNORED)
486
+				delete(watch.names, name)
487
+			}
488
+			if w.sendEvent(fullname, watch.mask&toFSnotifyFlags(raw.Action)) {
489
+				if watch.mask&sysFSONESHOT != 0 {
490
+					watch.mask = 0
491
+				}
492
+			}
493
+			if raw.Action == syscall.FILE_ACTION_RENAMED_NEW_NAME {
494
+				fullname = filepath.Join(watch.path, watch.rename)
495
+				sendNameEvent()
496
+			}
497
+
498
+			// Move to the next event in the buffer
499
+			if raw.NextEntryOffset == 0 {
500
+				break
501
+			}
502
+			offset += raw.NextEntryOffset
503
+
504
+			// Error!
505
+			if offset >= n {
506
+				w.Errors <- errors.New("Windows system assumed buffer larger than it is, events have likely been missed.")
507
+				break
508
+			}
509
+		}
510
+
511
+		if err := w.startRead(watch); err != nil {
512
+			w.Errors <- err
513
+		}
514
+	}
515
+}
516
+
517
+func (w *Watcher) sendEvent(name string, mask uint64) bool {
518
+	if mask == 0 {
519
+		return false
520
+	}
521
+	event := newEvent(name, uint32(mask))
522
+	select {
523
+	case ch := <-w.quit:
524
+		w.quit <- ch
525
+	case w.Events <- event:
526
+	}
527
+	return true
528
+}
529
+
530
+func toWindowsFlags(mask uint64) uint32 {
531
+	var m uint32
532
+	if mask&sysFSACCESS != 0 {
533
+		m |= syscall.FILE_NOTIFY_CHANGE_LAST_ACCESS
534
+	}
535
+	if mask&sysFSMODIFY != 0 {
536
+		m |= syscall.FILE_NOTIFY_CHANGE_LAST_WRITE
537
+	}
538
+	if mask&sysFSATTRIB != 0 {
539
+		m |= syscall.FILE_NOTIFY_CHANGE_ATTRIBUTES
540
+	}
541
+	if mask&(sysFSMOVE|sysFSCREATE|sysFSDELETE) != 0 {
542
+		m |= syscall.FILE_NOTIFY_CHANGE_FILE_NAME | syscall.FILE_NOTIFY_CHANGE_DIR_NAME
543
+	}
544
+	return m
545
+}
546
+
547
+func toFSnotifyFlags(action uint32) uint64 {
548
+	switch action {
549
+	case syscall.FILE_ACTION_ADDED:
550
+		return sysFSCREATE
551
+	case syscall.FILE_ACTION_REMOVED:
552
+		return sysFSDELETE
553
+	case syscall.FILE_ACTION_MODIFIED:
554
+		return sysFSMODIFY
555
+	case syscall.FILE_ACTION_RENAMED_OLD_NAME:
556
+		return sysFSMOVEDFROM
557
+	case syscall.FILE_ACTION_RENAMED_NEW_NAME:
558
+		return sysFSMOVEDTO
559
+	}
560
+	return 0
561
+}

+ 10
- 0
vendor/golang.org/x/sys/.gitattributes View File

@@ -0,0 +1,10 @@
1
+# Treat all files in this repo as binary, with no git magic updating
2
+# line endings. Windows users contributing to Go will need to use a
3
+# modern version of git and editors capable of LF line endings.
4
+#
5
+# We'll prevent accidental CRLF line endings from entering the repo
6
+# via the git-review gofmt checks.
7
+#
8
+# See golang.org/issue/9281
9
+
10
+* -text

+ 2
- 0
vendor/golang.org/x/sys/.gitignore View File

@@ -0,0 +1,2 @@
1
+# Add no patterns to .hgignore except for files generated by the build.
2
+last-change

+ 3
- 0
vendor/golang.org/x/sys/AUTHORS View File

@@ -0,0 +1,3 @@
1
+# This source code refers to The Go Authors for copyright purposes.
2
+# The master list of authors is in the main Go distribution,
3
+# visible at http://tip.golang.org/AUTHORS.

+ 31
- 0
vendor/golang.org/x/sys/CONTRIBUTING.md View File

@@ -0,0 +1,31 @@
1
+# Contributing to Go
2
+
3
+Go is an open source project.
4
+
5
+It is the work of hundreds of contributors. We appreciate your help!
6
+
7
+
8
+## Filing issues
9
+
10
+When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions:
11
+
12
+1. What version of Go are you using (`go version`)?
13
+2. What operating system and processor architecture are you using?
14
+3. What did you do?
15
+4. What did you expect to see?
16
+5. What did you see instead?
17
+
18
+General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker.
19
+The gophers there will answer or ask you to file an issue if you've tripped over a bug.
20
+
21
+## Contributing code
22
+
23
+Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html)
24
+before sending patches.
25
+
26
+**We do not accept GitHub pull requests**
27
+(we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review).
28
+
29
+Unless otherwise noted, the Go source files are distributed under
30
+the BSD-style license found in the LICENSE file.
31
+

+ 3
- 0
vendor/golang.org/x/sys/CONTRIBUTORS View File

@@ -0,0 +1,3 @@
1
+# This source code was written by the Go contributors.
2
+# The master list of contributors is in the main Go distribution,
3
+# visible at http://tip.golang.org/CONTRIBUTORS.

+ 27
- 0
vendor/golang.org/x/sys/LICENSE View File

@@ -0,0 +1,27 @@
1
+Copyright (c) 2009 The Go Authors. All rights reserved.
2
+
3
+Redistribution and use in source and binary forms, with or without
4
+modification, are permitted provided that the following conditions are
5
+met:
6
+
7
+   * Redistributions of source code must retain the above copyright
8
+notice, this list of conditions and the following disclaimer.
9
+   * Redistributions in binary form must reproduce the above
10
+copyright notice, this list of conditions and the following disclaimer
11
+in the documentation and/or other materials provided with the
12
+distribution.
13
+   * Neither the name of Google Inc. nor the names of its
14
+contributors may be used to endorse or promote products derived from
15
+this software without specific prior written permission.
16
+
17
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 22
- 0
vendor/golang.org/x/sys/PATENTS View File

@@ -0,0 +1,22 @@
1
+Additional IP Rights Grant (Patents)
2
+
3
+"This implementation" means the copyrightable works distributed by
4
+Google as part of the Go project.
5
+
6
+Google hereby grants to You a perpetual, worldwide, non-exclusive,
7
+no-charge, royalty-free, irrevocable (except as stated in this section)
8
+patent license to make, have made, use, offer to sell, sell, import,
9
+transfer and otherwise run, modify and propagate the contents of this
10
+implementation of Go, where such license applies only to those patent
11
+claims, both currently owned or controlled by Google and acquired in
12
+the future, licensable by Google that are necessarily infringed by this
13
+implementation of Go.  This grant does not include claims that would be
14
+infringed only as a consequence of further modification of this
15
+implementation.  If you or your agent or exclusive licensee institute or
16
+order or agree to the institution of patent litigation against any
17
+entity (including a cross-claim or counterclaim in a lawsuit) alleging
18
+that this implementation of Go or any code incorporated within this
19
+implementation of Go constitutes direct or contributory patent
20
+infringement, or inducement of patent infringement, then any patent
21
+rights granted to you under this License for this implementation of Go
22
+shall terminate as of the date such litigation is filed.

+ 3
- 0
vendor/golang.org/x/sys/README View File

@@ -0,0 +1,3 @@
1
+This repository holds supplemental Go packages for low-level interactions with the operating system.
2
+
3
+To submit changes to this repository, see http://golang.org/doc/contribute.html.

+ 1
- 0
vendor/golang.org/x/sys/codereview.cfg View File

@@ -0,0 +1 @@
1
+issuerepo: golang/go

+ 8
- 0
vendor/golang.org/x/sys/plan9/asm.s View File

@@ -0,0 +1,8 @@
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
+#include "textflag.h"
6
+
7
+TEXT ·use(SB),NOSPLIT,$0
8
+	RET

+ 30
- 0
vendor/golang.org/x/sys/plan9/asm_plan9_386.s View File

@@ -0,0 +1,30 @@
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
+#include "textflag.h"
6
+
7
+//
8
+// System call support for 386, Plan 9
9
+//
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-32
15
+	JMP	syscall·Syscall(SB)
16
+
17
+TEXT	·Syscall6(SB),NOSPLIT,$0-44
18
+	JMP	syscall·Syscall6(SB)
19
+
20
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
21
+	JMP	syscall·RawSyscall(SB)
22
+
23
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
24
+	JMP	syscall·RawSyscall6(SB)
25
+
26
+TEXT ·seek(SB),NOSPLIT,$0-36
27
+	JMP	syscall·seek(SB)
28
+
29
+TEXT ·exit(SB),NOSPLIT,$4-4
30
+	JMP	syscall·exit(SB)

+ 30
- 0
vendor/golang.org/x/sys/plan9/asm_plan9_amd64.s View File

@@ -0,0 +1,30 @@
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
+#include "textflag.h"
6
+
7
+//
8
+// System call support for amd64, Plan 9
9
+//
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-64
15
+	JMP	syscall·Syscall(SB)
16
+
17
+TEXT	·Syscall6(SB),NOSPLIT,$0-88
18
+	JMP	syscall·Syscall6(SB)
19
+
20
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
21
+	JMP	syscall·RawSyscall(SB)
22
+
23
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
24
+	JMP	syscall·RawSyscall6(SB)
25
+
26
+TEXT ·seek(SB),NOSPLIT,$0-56
27
+	JMP	syscall·seek(SB)
28
+
29
+TEXT ·exit(SB),NOSPLIT,$8-8
30
+	JMP	syscall·exit(SB)

+ 70
- 0
vendor/golang.org/x/sys/plan9/const_plan9.go View File

@@ -0,0 +1,70 @@
1
+package plan9
2
+
3
+// Plan 9 Constants
4
+
5
+// Open modes
6
+const (
7
+	O_RDONLY  = 0
8
+	O_WRONLY  = 1
9
+	O_RDWR    = 2
10
+	O_TRUNC   = 16
11
+	O_CLOEXEC = 32
12
+	O_EXCL    = 0x1000
13
+)
14
+
15
+// Rfork flags
16
+const (
17
+	RFNAMEG  = 1 << 0
18
+	RFENVG   = 1 << 1
19
+	RFFDG    = 1 << 2
20
+	RFNOTEG  = 1 << 3
21
+	RFPROC   = 1 << 4
22
+	RFMEM    = 1 << 5
23
+	RFNOWAIT = 1 << 6
24
+	RFCNAMEG = 1 << 10
25
+	RFCENVG  = 1 << 11
26
+	RFCFDG   = 1 << 12
27
+	RFREND   = 1 << 13
28
+	RFNOMNT  = 1 << 14
29
+)
30
+
31
+// Qid.Type bits
32
+const (
33
+	QTDIR    = 0x80
34
+	QTAPPEND = 0x40
35
+	QTEXCL   = 0x20
36
+	QTMOUNT  = 0x10
37
+	QTAUTH   = 0x08
38
+	QTTMP    = 0x04
39
+	QTFILE   = 0x00
40
+)
41
+
42
+// Dir.Mode bits
43
+const (
44
+	DMDIR    = 0x80000000
45
+	DMAPPEND = 0x40000000
46
+	DMEXCL   = 0x20000000
47
+	DMMOUNT  = 0x10000000
48
+	DMAUTH   = 0x08000000
49
+	DMTMP    = 0x04000000
50
+	DMREAD   = 0x4
51
+	DMWRITE  = 0x2
52
+	DMEXEC   = 0x1
53
+)
54
+
55
+const (
56
+	STATMAX    = 65535
57
+	ERRMAX     = 128
58
+	STATFIXLEN = 49
59
+)
60
+
61
+// Mount and bind flags
62
+const (
63
+	MREPL   = 0x0000
64
+	MBEFORE = 0x0001
65
+	MAFTER  = 0x0002
66
+	MORDER  = 0x0003
67
+	MCREATE = 0x0004
68
+	MCACHE  = 0x0010
69
+	MMASK   = 0x0017
70
+)

+ 212
- 0
vendor/golang.org/x/sys/plan9/dir_plan9.go View File

@@ -0,0 +1,212 @@
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
+// Plan 9 directory marshalling. See intro(5).
6
+
7
+package plan9
8
+
9
+import "errors"
10
+
11
+var (
12
+	ErrShortStat = errors.New("stat buffer too short")
13
+	ErrBadStat   = errors.New("malformed stat buffer")
14
+	ErrBadName   = errors.New("bad character in file name")
15
+)
16
+
17
+// A Qid represents a 9P server's unique identification for a file.
18
+type Qid struct {
19
+	Path uint64 // the file server's unique identification for the file
20
+	Vers uint32 // version number for given Path
21
+	Type uint8  // the type of the file (plan9.QTDIR for example)
22
+}
23
+
24
+// A Dir contains the metadata for a file.
25
+type Dir struct {
26
+	// system-modified data
27
+	Type uint16 // server type
28
+	Dev  uint32 // server subtype
29
+
30
+	// file data
31
+	Qid    Qid    // unique id from server
32
+	Mode   uint32 // permissions
33
+	Atime  uint32 // last read time
34
+	Mtime  uint32 // last write time
35
+	Length int64  // file length
36
+	Name   string // last element of path
37
+	Uid    string // owner name
38
+	Gid    string // group name
39
+	Muid   string // last modifier name
40
+}
41
+
42
+var nullDir = Dir{
43
+	Type: ^uint16(0),
44
+	Dev:  ^uint32(0),
45
+	Qid: Qid{
46
+		Path: ^uint64(0),
47
+		Vers: ^uint32(0),
48
+		Type: ^uint8(0),
49
+	},
50
+	Mode:   ^uint32(0),
51
+	Atime:  ^uint32(0),
52
+	Mtime:  ^uint32(0),
53
+	Length: ^int64(0),
54
+}
55
+
56
+// Null assigns special "don't touch" values to members of d to
57
+// avoid modifying them during plan9.Wstat.
58
+func (d *Dir) Null() { *d = nullDir }
59
+
60
+// Marshal encodes a 9P stat message corresponding to d into b
61
+//
62
+// If there isn't enough space in b for a stat message, ErrShortStat is returned.
63
+func (d *Dir) Marshal(b []byte) (n int, err error) {
64
+	n = STATFIXLEN + len(d.Name) + len(d.Uid) + len(d.Gid) + len(d.Muid)
65
+	if n > len(b) {
66
+		return n, ErrShortStat
67
+	}
68
+
69
+	for _, c := range d.Name {
70
+		if c == '/' {
71
+			return n, ErrBadName
72
+		}
73
+	}
74
+
75
+	b = pbit16(b, uint16(n)-2)
76
+	b = pbit16(b, d.Type)
77
+	b = pbit32(b, d.Dev)
78
+	b = pbit8(b, d.Qid.Type)
79
+	b = pbit32(b, d.Qid.Vers)
80
+	b = pbit64(b, d.Qid.Path)
81
+	b = pbit32(b, d.Mode)
82
+	b = pbit32(b, d.Atime)
83
+	b = pbit32(b, d.Mtime)
84
+	b = pbit64(b, uint64(d.Length))
85
+	b = pstring(b, d.Name)
86
+	b = pstring(b, d.Uid)
87
+	b = pstring(b, d.Gid)
88
+	b = pstring(b, d.Muid)
89
+
90
+	return n, nil
91
+}
92
+
93
+// UnmarshalDir decodes a single 9P stat message from b and returns the resulting Dir.
94
+//
95
+// If b is too small to hold a valid stat message, ErrShortStat is returned.
96
+//
97
+// If the stat message itself is invalid, ErrBadStat is returned.
98
+func UnmarshalDir(b []byte) (*Dir, error) {
99
+	if len(b) < STATFIXLEN {
100
+		return nil, ErrShortStat
101
+	}
102
+	size, buf := gbit16(b)
103
+	if len(b) != int(size)+2 {
104
+		return nil, ErrBadStat
105
+	}
106
+	b = buf
107
+
108
+	var d Dir
109
+	d.Type, b = gbit16(b)
110
+	d.Dev, b = gbit32(b)
111
+	d.Qid.Type, b = gbit8(b)
112
+	d.Qid.Vers, b = gbit32(b)
113
+	d.Qid.Path, b = gbit64(b)
114
+	d.Mode, b = gbit32(b)
115
+	d.Atime, b = gbit32(b)
116
+	d.Mtime, b = gbit32(b)
117
+
118
+	n, b := gbit64(b)
119
+	d.Length = int64(n)
120
+
121
+	var ok bool
122
+	if d.Name, b, ok = gstring(b); !ok {
123
+		return nil, ErrBadStat
124
+	}
125
+	if d.Uid, b, ok = gstring(b); !ok {
126
+		return nil, ErrBadStat
127
+	}
128
+	if d.Gid, b, ok = gstring(b); !ok {
129
+		return nil, ErrBadStat
130
+	}
131
+	if d.Muid, b, ok = gstring(b); !ok {
132
+		return nil, ErrBadStat
133
+	}
134
+
135
+	return &d, nil
136
+}
137
+
138
+// pbit8 copies the 8-bit number v to b and returns the remaining slice of b.
139
+func pbit8(b []byte, v uint8) []byte {
140
+	b[0] = byte(v)
141
+	return b[1:]
142
+}
143
+
144
+// pbit16 copies the 16-bit number v to b in little-endian order and returns the remaining slice of b.
145
+func pbit16(b []byte, v uint16) []byte {
146
+	b[0] = byte(v)
147
+	b[1] = byte(v >> 8)
148
+	return b[2:]
149
+}
150
+
151
+// pbit32 copies the 32-bit number v to b in little-endian order and returns the remaining slice of b.
152
+func pbit32(b []byte, v uint32) []byte {
153
+	b[0] = byte(v)
154
+	b[1] = byte(v >> 8)
155
+	b[2] = byte(v >> 16)
156
+	b[3] = byte(v >> 24)
157
+	return b[4:]
158
+}
159
+
160
+// pbit64 copies the 64-bit number v to b in little-endian order and returns the remaining slice of b.
161
+func pbit64(b []byte, v uint64) []byte {
162
+	b[0] = byte(v)
163
+	b[1] = byte(v >> 8)
164
+	b[2] = byte(v >> 16)
165
+	b[3] = byte(v >> 24)
166
+	b[4] = byte(v >> 32)
167
+	b[5] = byte(v >> 40)
168
+	b[6] = byte(v >> 48)
169
+	b[7] = byte(v >> 56)
170
+	return b[8:]
171
+}
172
+
173
+// pstring copies the string s to b, prepending it with a 16-bit length in little-endian order, and
174
+// returning the remaining slice of b..
175
+func pstring(b []byte, s string) []byte {
176
+	b = pbit16(b, uint16(len(s)))
177
+	n := copy(b, s)
178
+	return b[n:]
179
+}
180
+
181
+// gbit8 reads an 8-bit number from b and returns it with the remaining slice of b.
182
+func gbit8(b []byte) (uint8, []byte) {
183
+	return uint8(b[0]), b[1:]
184
+}
185
+
186
+// gbit16 reads a 16-bit number in little-endian order from b and returns it with the remaining slice of b.
187
+func gbit16(b []byte) (uint16, []byte) {
188
+	return uint16(b[0]) | uint16(b[1])<<8, b[2:]
189
+}
190
+
191
+// gbit32 reads a 32-bit number in little-endian order from b and returns it with the remaining slice of b.
192
+func gbit32(b []byte) (uint32, []byte) {
193
+	return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24, b[4:]
194
+}
195
+
196
+// gbit64 reads a 64-bit number in little-endian order from b and returns it with the remaining slice of b.
197
+func gbit64(b []byte) (uint64, []byte) {
198
+	lo := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
199
+	hi := uint32(b[4]) | uint32(b[5])<<8 | uint32(b[6])<<16 | uint32(b[7])<<24
200
+	return uint64(lo) | uint64(hi)<<32, b[8:]
201
+}
202
+
203
+// gstring reads a string from b, prefixed with a 16-bit length in little-endian order.
204
+// It returns the string with the remaining slice of b and a boolean. If the length is
205
+// greater than the number of bytes in b, the boolean will be false.
206
+func gstring(b []byte) (string, []byte, bool) {
207
+	n, b := gbit16(b)
208
+	if int(n) > len(b) {
209
+		return "", b, false
210
+	}
211
+	return string(b[:n]), b[n:], true
212
+}

+ 27
- 0
vendor/golang.org/x/sys/plan9/env_plan9.go View File

@@ -0,0 +1,27 @@
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
+// Plan 9 environment variables.
6
+
7
+package plan9
8
+
9
+import (
10
+	"syscall"
11
+)
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/golang.org/x/sys/plan9/env_unset.go View File

@@ -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 plan9
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
+}

+ 50
- 0
vendor/golang.org/x/sys/plan9/errors_plan9.go View File

@@ -0,0 +1,50 @@
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 plan9
6
+
7
+import "syscall"
8
+
9
+// Constants
10
+const (
11
+	// Invented values to support what package os expects.
12
+	O_CREAT    = 0x02000
13
+	O_APPEND   = 0x00400
14
+	O_NOCTTY   = 0x00000
15
+	O_NONBLOCK = 0x00000
16
+	O_SYNC     = 0x00000
17
+	O_ASYNC    = 0x00000
18
+
19
+	S_IFMT   = 0x1f000
20
+	S_IFIFO  = 0x1000
21
+	S_IFCHR  = 0x2000
22
+	S_IFDIR  = 0x4000
23
+	S_IFBLK  = 0x6000
24
+	S_IFREG  = 0x8000
25
+	S_IFLNK  = 0xa000
26
+	S_IFSOCK = 0xc000
27
+)
28
+
29
+// Errors
30
+var (
31
+	EINVAL       = syscall.NewError("bad arg in system call")
32
+	ENOTDIR      = syscall.NewError("not a directory")
33
+	EISDIR       = syscall.NewError("file is a directory")
34
+	ENOENT       = syscall.NewError("file does not exist")
35
+	EEXIST       = syscall.NewError("file already exists")
36
+	EMFILE       = syscall.NewError("no free file descriptors")
37
+	EIO          = syscall.NewError("i/o error")
38
+	ENAMETOOLONG = syscall.NewError("file name too long")
39
+	EINTR        = syscall.NewError("interrupted")
40
+	EPERM        = syscall.NewError("permission denied")
41
+	EBUSY        = syscall.NewError("no free devices")
42
+	ETIMEDOUT    = syscall.NewError("connection timed out")
43
+	EPLAN9       = syscall.NewError("not supported by plan 9")
44
+
45
+	// The following errors do not correspond to any
46
+	// Plan 9 system messages. Invented to support
47
+	// what package os and others expect.
48
+	EACCES       = syscall.NewError("access permission denied")
49
+	EAFNOSUPPORT = syscall.NewError("address family not supported by protocol")
50
+)

+ 138
- 0
vendor/golang.org/x/sys/plan9/mkall.sh View File

@@ -0,0 +1,138 @@
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
+# The plan9 package provides access to the raw system call
7
+# interface of the underlying operating system.  Porting Go to
8
+# a new architecture/operating system combination requires
9
+# some manual effort, though there are tools that automate
10
+# much of the process.  The auto-generated files have names
11
+# beginning with z.
12
+#
13
+# This script runs or (given -n) prints suggested commands to generate z files
14
+# for the current system.  Running those commands is not automatic.
15
+# This script is documentation more than anything else.
16
+#
17
+# * asm_${GOOS}_${GOARCH}.s
18
+#
19
+# This hand-written assembly file implements system call dispatch.
20
+# There are three entry points:
21
+#
22
+# 	func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
23
+# 	func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
24
+# 	func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
25
+#
26
+# The first and second are the standard ones; they differ only in
27
+# how many arguments can be passed to the kernel.
28
+# The third is for low-level use by the ForkExec wrapper;
29
+# unlike the first two, it does not call into the scheduler to
30
+# let it know that a system call is running.
31
+#
32
+# * syscall_${GOOS}.go
33
+#
34
+# This hand-written Go file implements system calls that need
35
+# special handling and lists "//sys" comments giving prototypes
36
+# for ones that can be auto-generated.  Mksyscall reads those
37
+# comments to generate the stubs.
38
+#
39
+# * syscall_${GOOS}_${GOARCH}.go
40
+#
41
+# Same as syscall_${GOOS}.go except that it contains code specific
42
+# to ${GOOS} on one particular architecture.
43
+#
44
+# * types_${GOOS}.c
45
+#
46
+# This hand-written C file includes standard C headers and then
47
+# creates typedef or enum names beginning with a dollar sign
48
+# (use of $ in variable names is a gcc extension).  The hardest
49
+# part about preparing this file is figuring out which headers to
50
+# include and which symbols need to be #defined to get the
51
+# actual data structures that pass through to the kernel system calls.
52
+# Some C libraries present alternate versions for binary compatibility
53
+# and translate them on the way in and out of system calls, but
54
+# there is almost always a #define that can get the real ones.
55
+# See types_darwin.c and types_linux.c for examples.
56
+#
57
+# * zerror_${GOOS}_${GOARCH}.go
58
+#
59
+# This machine-generated file defines the system's error numbers,
60
+# error strings, and signal numbers.  The generator is "mkerrors.sh".
61
+# Usually no arguments are needed, but mkerrors.sh will pass its
62
+# arguments on to godefs.
63
+#
64
+# * zsyscall_${GOOS}_${GOARCH}.go
65
+#
66
+# Generated by mksyscall.pl; see syscall_${GOOS}.go above.
67
+#
68
+# * zsysnum_${GOOS}_${GOARCH}.go
69
+#
70
+# Generated by mksysnum_${GOOS}.
71
+#
72
+# * ztypes_${GOOS}_${GOARCH}.go
73
+#
74
+# Generated by godefs; see types_${GOOS}.c above.
75
+
76
+GOOSARCH="${GOOS}_${GOARCH}"
77
+
78
+# defaults
79
+mksyscall="./mksyscall.pl"
80
+mkerrors="./mkerrors.sh"
81
+zerrors="zerrors_$GOOSARCH.go"
82
+mksysctl=""
83
+zsysctl="zsysctl_$GOOSARCH.go"
84
+mksysnum=
85
+mktypes=
86
+run="sh"
87
+
88
+case "$1" in
89
+-syscalls)
90
+	for i in zsyscall*go
91
+	do
92
+		sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
93
+		rm _$i
94
+	done
95
+	exit 0
96
+	;;
97
+-n)
98
+	run="cat"
99
+	shift
100
+esac
101
+
102
+case "$#" in
103
+0)
104
+	;;
105
+*)
106
+	echo 'usage: mkall.sh [-n]' 1>&2
107
+	exit 2
108
+esac
109
+
110
+case "$GOOSARCH" in
111
+_* | *_ | _)
112
+	echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
113
+	exit 1
114
+	;;
115
+plan9_386)
116
+	mkerrors=
117
+	mksyscall="./mksyscall.pl -l32 -plan9"
118
+	mksysnum="./mksysnum_plan9.sh /n/sources/plan9/sys/src/libc/9syscall/sys.h"
119
+	mktypes="XXX"
120
+	;;
121
+*)
122
+	echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
123
+	exit 1
124
+	;;
125
+esac
126
+
127
+(
128
+	if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
129
+	case "$GOOS" in
130
+	plan9)
131
+		syscall_goos="syscall_$GOOS.go"
132
+		if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos syscall_$GOOSARCH.go |gofmt >zsyscall_$GOOSARCH.go"; fi
133
+		;;
134
+	esac
135
+	if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
136
+	if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
137
+	if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go |gofmt >ztypes_$GOOSARCH.go"; fi
138
+) | $run

+ 246
- 0
vendor/golang.org/x/sys/plan9/mkerrors.sh View File

@@ -0,0 +1,246 @@
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
+CC=${CC:-gcc}
15
+
16
+uname=$(uname)
17
+
18
+includes='
19
+#include <sys/types.h>
20
+#include <sys/file.h>
21
+#include <fcntl.h>
22
+#include <dirent.h>
23
+#include <sys/socket.h>
24
+#include <netinet/in.h>
25
+#include <netinet/ip.h>
26
+#include <netinet/ip6.h>
27
+#include <netinet/tcp.h>
28
+#include <errno.h>
29
+#include <sys/signal.h>
30
+#include <signal.h>
31
+#include <sys/resource.h>
32
+'
33
+
34
+ccflags="$@"
35
+
36
+# Write go tool cgo -godefs input.
37
+(
38
+	echo package plan9
39
+	echo
40
+	echo '/*'
41
+	indirect="includes_$(uname)"
42
+	echo "${!indirect} $includes"
43
+	echo '*/'
44
+	echo 'import "C"'
45
+	echo
46
+	echo 'const ('
47
+
48
+	# The gcc command line prints all the #defines
49
+	# it encounters while processing the input
50
+	echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags |
51
+	awk '
52
+		$1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
53
+
54
+		$2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next}  # 386 registers
55
+		$2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next}
56
+		$2 ~ /^(SCM_SRCRT)$/ {next}
57
+		$2 ~ /^(MAP_FAILED)$/ {next}
58
+
59
+		$2 !~ /^ETH_/ &&
60
+		$2 !~ /^EPROC_/ &&
61
+		$2 !~ /^EQUIV_/ &&
62
+		$2 !~ /^EXPR_/ &&
63
+		$2 ~ /^E[A-Z0-9_]+$/ ||
64
+		$2 ~ /^B[0-9_]+$/ ||
65
+		$2 ~ /^V[A-Z0-9]+$/ ||
66
+		$2 ~ /^CS[A-Z0-9]/ ||
67
+		$2 ~ /^I(SIG|CANON|CRNL|EXTEN|MAXBEL|STRIP|UTF8)$/ ||
68
+		$2 ~ /^IGN/ ||
69
+		$2 ~ /^IX(ON|ANY|OFF)$/ ||
70
+		$2 ~ /^IN(LCR|PCK)$/ ||
71
+		$2 ~ /(^FLU?SH)|(FLU?SH$)/ ||
72
+		$2 ~ /^C(LOCAL|READ)$/ ||
73
+		$2 == "BRKINT" ||
74
+		$2 == "HUPCL" ||
75
+		$2 == "PENDIN" ||
76
+		$2 == "TOSTOP" ||
77
+		$2 ~ /^PAR/ ||
78
+		$2 ~ /^SIG[^_]/ ||
79
+		$2 ~ /^O[CNPFP][A-Z]+[^_][A-Z]+$/ ||
80
+		$2 ~ /^IN_/ ||
81
+		$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
82
+		$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
83
+		$2 == "ICMPV6_FILTER" ||
84
+		$2 == "SOMAXCONN" ||
85
+		$2 == "NAME_MAX" ||
86
+		$2 == "IFNAMSIZ" ||
87
+		$2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
88
+		$2 ~ /^SYSCTL_VERS/ ||
89
+		$2 ~ /^(MS|MNT)_/ ||
90
+		$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
91
+		$2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ ||
92
+		$2 ~ /^LINUX_REBOOT_CMD_/ ||
93
+		$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
94
+		$2 !~ "NLA_TYPE_MASK" &&
95
+		$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
96
+		$2 ~ /^SIOC/ ||
97
+		$2 ~ /^TIOC/ ||
98
+		$2 !~ "RTF_BITS" &&
99
+		$2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
100
+		$2 ~ /^BIOC/ ||
101
+		$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
102
+		$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ ||
103
+		$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
104
+		$2 ~ /^CLONE_[A-Z_]+/ ||
105
+		$2 !~ /^(BPF_TIMEVAL)$/ &&
106
+		$2 ~ /^(BPF|DLT)_/ ||
107
+		$2 !~ "WMESGLEN" &&
108
+		$2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)}
109
+		$2 ~ /^__WCOREFLAG$/ {next}
110
+		$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
111
+
112
+		{next}
113
+	' | sort
114
+
115
+	echo ')'
116
+) >_const.go
117
+
118
+# Pull out the error names for later.
119
+errors=$(
120
+	echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
121
+	awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
122
+	sort
123
+)
124
+
125
+# Pull out the signal names for later.
126
+signals=$(
127
+	echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
128
+	awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
129
+	egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
130
+	sort
131
+)
132
+
133
+# Again, writing regexps to a file.
134
+echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
135
+	awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' |
136
+	sort >_error.grep
137
+echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
138
+	awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
139
+	egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
140
+	sort >_signal.grep
141
+
142
+echo '// mkerrors.sh' "$@"
143
+echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT'
144
+echo
145
+go tool cgo -godefs -- "$@" _const.go >_error.out
146
+cat _error.out | grep -vf _error.grep | grep -vf _signal.grep
147
+echo
148
+echo '// Errors'
149
+echo 'const ('
150
+cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= Errno(\1)/'
151
+echo ')'
152
+
153
+echo
154
+echo '// Signals'
155
+echo 'const ('
156
+cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= Signal(\1)/'
157
+echo ')'
158
+
159
+# Run C program to print error and syscall strings.
160
+(
161
+	echo -E "
162
+#include <stdio.h>
163
+#include <stdlib.h>
164
+#include <errno.h>
165
+#include <ctype.h>
166
+#include <string.h>
167
+#include <signal.h>
168
+
169
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
170
+
171
+enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below
172
+
173
+int errors[] = {
174
+"
175
+	for i in $errors
176
+	do
177
+		echo -E '	'$i,
178
+	done
179
+
180
+	echo -E "
181
+};
182
+
183
+int signals[] = {
184
+"
185
+	for i in $signals
186
+	do
187
+		echo -E '	'$i,
188
+	done
189
+
190
+	# Use -E because on some systems bash builtin interprets \n itself.
191
+	echo -E '
192
+};
193
+
194
+static int
195
+intcmp(const void *a, const void *b)
196
+{
197
+	return *(int*)a - *(int*)b;
198
+}
199
+
200
+int
201
+main(void)
202
+{
203
+	int i, j, e;
204
+	char buf[1024], *p;
205
+
206
+	printf("\n\n// Error table\n");
207
+	printf("var errors = [...]string {\n");
208
+	qsort(errors, nelem(errors), sizeof errors[0], intcmp);
209
+	for(i=0; i<nelem(errors); i++) {
210
+		e = errors[i];
211
+		if(i > 0 && errors[i-1] == e)
212
+			continue;
213
+		strcpy(buf, strerror(e));
214
+		// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
215
+		if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
216
+			buf[0] += a - A;
217
+		printf("\t%d: \"%s\",\n", e, buf);
218
+	}
219
+	printf("}\n\n");
220
+	
221
+	printf("\n\n// Signal table\n");
222
+	printf("var signals = [...]string {\n");
223
+	qsort(signals, nelem(signals), sizeof signals[0], intcmp);
224
+	for(i=0; i<nelem(signals); i++) {
225
+		e = signals[i];
226
+		if(i > 0 && signals[i-1] == e)
227
+			continue;
228
+		strcpy(buf, strsignal(e));
229
+		// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
230
+		if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
231
+			buf[0] += a - A;
232
+		// cut trailing : number.
233
+		p = strrchr(buf, ":"[0]);
234
+		if(p)
235
+			*p = '\0';
236
+		printf("\t%d: \"%s\",\n", e, buf);
237
+	}
238
+	printf("}\n\n");
239
+
240
+	return 0;
241
+}
242
+
243
+'
244
+) >_errors.c
245
+
246
+$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out

+ 319
- 0
vendor/golang.org/x/sys/plan9/mksyscall.pl View File

@@ -0,0 +1,319 @@
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_plan9.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 $nacl = 0;
32
+my $arm = 0; # 64-bit value should use (even, odd)-pair
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 "-nacl") {
58
+	$nacl = 1;
59
+	shift;
60
+}
61
+if($ARGV[0] eq "-arm") {
62
+	$arm = 1;
63
+	shift;
64
+}
65
+
66
+if($ARGV[0] =~ /^-/) {
67
+	print STDERR "usage: mksyscall.pl [-b32 | -l32] [file ...]\n";
68
+	exit 1;
69
+}
70
+
71
+sub parseparamlist($) {
72
+	my ($list) = @_;
73
+	$list =~ s/^\s*//;
74
+	$list =~ s/\s*$//;
75
+	if($list eq "") {
76
+		return ();
77
+	}
78
+	return split(/\s*,\s*/, $list);
79
+}
80
+
81
+sub parseparam($) {
82
+	my ($p) = @_;
83
+	if($p !~ /^(\S*) (\S*)$/) {
84
+		print STDERR "$ARGV:$.: malformed parameter: $p\n";
85
+		$errors = 1;
86
+		return ("xx", "int");
87
+	}
88
+	return ($1, $2);
89
+}
90
+
91
+my $text = "";
92
+while(<>) {
93
+	chomp;
94
+	s/\s+/ /g;
95
+	s/^\s+//;
96
+	s/\s+$//;
97
+	my $nonblock = /^\/\/sysnb /;
98
+	next if !/^\/\/sys / && !$nonblock;
99
+
100
+	# Line must be of the form
101
+	#	func Open(path string, mode int, perm int) (fd int, errno error)
102
+	# Split into name, in params, out params.
103
+	if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) {
104
+		print STDERR "$ARGV:$.: malformed //sys declaration\n";
105
+		$errors = 1;
106
+		next;
107
+	}
108
+	my ($func, $in, $out, $sysname) = ($2, $3, $4, $5);
109
+
110
+	# Split argument lists on comma.
111
+	my @in = parseparamlist($in);
112
+	my @out = parseparamlist($out);
113
+
114
+	# Try in vain to keep people from editing this file.
115
+	# The theory is that they jump into the middle of the file
116
+	# without reading the header.
117
+	$text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
118
+
119
+	# Go function header.
120
+	my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
121
+	$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
122
+
123
+	# Check if err return available
124
+	my $errvar = "";
125
+	foreach my $p (@out) {
126
+		my ($name, $type) = parseparam($p);
127
+		if($type eq "error") {
128
+			$errvar = $name;
129
+			last;
130
+		}
131
+	}
132
+
133
+	# Prepare arguments to Syscall.
134
+	my @args = ();
135
+	my @uses = ();
136
+	my $n = 0;
137
+	foreach my $p (@in) {
138
+		my ($name, $type) = parseparam($p);
139
+		if($type =~ /^\*/) {
140
+			push @args, "uintptr(unsafe.Pointer($name))";
141
+		} elsif($type eq "string" && $errvar ne "") {
142
+			$text .= "\tvar _p$n *byte\n";
143
+			$text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
144
+			$text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
145
+			push @args, "uintptr(unsafe.Pointer(_p$n))";
146
+			push @uses, "use(unsafe.Pointer(_p$n))";
147
+			$n++;
148
+		} elsif($type eq "string") {
149
+			print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
150
+			$text .= "\tvar _p$n *byte\n";
151
+			$text .= "\t_p$n, _ = BytePtrFromString($name)\n";
152
+			push @args, "uintptr(unsafe.Pointer(_p$n))";
153
+			push @uses, "use(unsafe.Pointer(_p$n))";
154
+			$n++;
155
+		} elsif($type =~ /^\[\](.*)/) {
156
+			# Convert slice into pointer, length.
157
+			# Have to be careful not to take address of &a[0] if len == 0:
158
+			# pass dummy pointer in that case.
159
+			# Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
160
+			$text .= "\tvar _p$n unsafe.Pointer\n";
161
+			$text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}";
162
+			$text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}";
163
+			$text .= "\n";
164
+			push @args, "uintptr(_p$n)", "uintptr(len($name))";
165
+			$n++;
166
+		} elsif($type eq "int64" && ($openbsd || $netbsd)) {
167
+			push @args, "0";
168
+			if($_32bit eq "big-endian") {
169
+				push @args, "uintptr($name>>32)", "uintptr($name)";
170
+			} elsif($_32bit eq "little-endian") {
171
+				push @args, "uintptr($name)", "uintptr($name>>32)";
172
+			} else {
173
+				push @args, "uintptr($name)";
174
+			}
175
+		} elsif($type eq "int64" && $dragonfly) {
176
+			if ($func !~ /^extp(read|write)/i) {
177
+				push @args, "0";
178
+			}
179
+			if($_32bit eq "big-endian") {
180
+				push @args, "uintptr($name>>32)", "uintptr($name)";
181
+			} elsif($_32bit eq "little-endian") {
182
+				push @args, "uintptr($name)", "uintptr($name>>32)";
183
+			} else {
184
+				push @args, "uintptr($name)";
185
+			}
186
+		} elsif($type eq "int64" && $_32bit ne "") {
187
+			if(@args % 2 && $arm) {
188
+				# arm abi specifies 64-bit argument uses 
189
+				# (even, odd) pair
190
+				push @args, "0"
191
+			}
192
+			if($_32bit eq "big-endian") {
193
+				push @args, "uintptr($name>>32)", "uintptr($name)";
194
+			} else {
195
+				push @args, "uintptr($name)", "uintptr($name>>32)";
196
+			}
197
+		} else {
198
+			push @args, "uintptr($name)";
199
+		}
200
+	}
201
+
202
+	# Determine which form to use; pad args with zeros.
203
+	my $asm = "Syscall";
204
+	if ($nonblock) {
205
+		$asm = "RawSyscall";
206
+	}
207
+	if(@args <= 3) {
208
+		while(@args < 3) {
209
+			push @args, "0";
210
+		}
211
+	} elsif(@args <= 6) {
212
+		$asm .= "6";
213
+		while(@args < 6) {
214
+			push @args, "0";
215
+		}
216
+	} elsif(@args <= 9) {
217
+		$asm .= "9";
218
+		while(@args < 9) {
219
+			push @args, "0";
220
+		}
221
+	} else {
222
+		print STDERR "$ARGV:$.: too many arguments to system call\n";
223
+	}
224
+
225
+	# System call number.
226
+	if($sysname eq "") {
227
+		$sysname = "SYS_$func";
228
+		$sysname =~ s/([a-z])([A-Z])/${1}_$2/g;	# turn FooBar into Foo_Bar
229
+		$sysname =~ y/a-z/A-Z/;
230
+		if($nacl) {
231
+			$sysname =~ y/A-Z/a-z/;
232
+		}
233
+	}
234
+
235
+	# Actual call.
236
+	my $args = join(', ', @args);
237
+	my $call = "$asm($sysname, $args)";
238
+
239
+	# Assign return values.
240
+	my $body = "";
241
+	my @ret = ("_", "_", "_");
242
+	my $do_errno = 0;
243
+	for(my $i=0; $i<@out; $i++) {
244
+		my $p = $out[$i];
245
+		my ($name, $type) = parseparam($p);
246
+		my $reg = "";
247
+		if($name eq "err" && !$plan9) {
248
+			$reg = "e1";
249
+			$ret[2] = $reg;
250
+			$do_errno = 1;
251
+		} elsif($name eq "err" && $plan9) {
252
+			$ret[0] = "r0";
253
+			$ret[2] = "e1";
254
+			next;
255
+		} else {
256
+			$reg = sprintf("r%d", $i);
257
+			$ret[$i] = $reg;
258
+		}
259
+		if($type eq "bool") {
260
+			$reg = "$reg != 0";
261
+		}
262
+		if($type eq "int64" && $_32bit ne "") {
263
+			# 64-bit number in r1:r0 or r0:r1.
264
+			if($i+2 > @out) {
265
+				print STDERR "$ARGV:$.: not enough registers for int64 return\n";
266
+			}
267
+			if($_32bit eq "big-endian") {
268
+				$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
269
+			} else {
270
+				$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
271
+			}
272
+			$ret[$i] = sprintf("r%d", $i);
273
+			$ret[$i+1] = sprintf("r%d", $i+1);
274
+		}
275
+		if($reg ne "e1" || $plan9) {
276
+			$body .= "\t$name = $type($reg)\n";
277
+		}
278
+	}
279
+	if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
280
+		$text .= "\t$call\n";
281
+	} else {
282
+		$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
283
+	}
284
+	foreach my $use (@uses) {
285
+		$text .= "\t$use\n";
286
+	}
287
+	$text .= $body;
288
+	
289
+	if ($plan9 && $ret[2] eq "e1") {
290
+		$text .= "\tif int32(r0) == -1 {\n";
291
+		$text .= "\t\terr = e1\n";
292
+		$text .= "\t}\n";
293
+	} elsif ($do_errno) {
294
+		$text .= "\tif e1 != 0 {\n";
295
+		$text .= "\t\terr = e1\n";
296
+		$text .= "\t}\n";
297
+	}
298
+	$text .= "\treturn\n";
299
+	$text .= "}\n\n";
300
+}
301
+
302
+chomp $text;
303
+chomp $text;
304
+
305
+if($errors) {
306
+	exit 1;
307
+}
308
+
309
+print <<EOF;
310
+// $cmdline
311
+// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
312
+
313
+package plan9
314
+
315
+import "unsafe"
316
+
317
+$text
318
+EOF
319
+exit 0;

+ 23
- 0
vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh View File

@@ -0,0 +1,23 @@
1
+#!/bin/sh
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
+COMMAND="mksysnum_plan9.sh $@"
7
+
8
+cat <<EOF
9
+// $COMMAND
10
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
11
+
12
+package plan9
13
+
14
+const(
15
+EOF
16
+
17
+SP='[ 	]' # space or tab
18
+sed "s/^#define${SP}\\([A-Z0-9_][A-Z0-9_]*\\)${SP}${SP}*\\([0-9][0-9]*\\)/SYS_\\1=\\2/g" \
19
+	< $1 | grep -v SYS__
20
+
21
+cat <<EOF
22
+)
23
+EOF

+ 21
- 0
vendor/golang.org/x/sys/plan9/pwd_go15_plan9.go View File

@@ -0,0 +1,21 @@
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 go1.5
6
+
7
+package plan9
8
+
9
+import "syscall"
10
+
11
+func fixwd() {
12
+	syscall.Fixwd()
13
+}
14
+
15
+func Getwd() (wd string, err error) {
16
+	return syscall.Getwd()
17
+}
18
+
19
+func Chdir(path string) error {
20
+	return syscall.Chdir(path)
21
+}

+ 23
- 0
vendor/golang.org/x/sys/plan9/pwd_plan9.go View File

@@ -0,0 +1,23 @@
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 !go1.5
6
+
7
+package plan9
8
+
9
+func fixwd() {
10
+}
11
+
12
+func Getwd() (wd string, err error) {
13
+	fd, err := open(".", O_RDONLY)
14
+	if err != nil {
15
+		return "", err
16
+	}
17
+	defer Close(fd)
18
+	return Fd2path(fd)
19
+}
20
+
21
+func Chdir(path string) error {
22
+	return chdir(path)
23
+}

+ 30
- 0
vendor/golang.org/x/sys/plan9/race.go View File

@@ -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 plan9,race
6
+
7
+package plan9
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/golang.org/x/sys/plan9/race0.go View File

@@ -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 plan9,!race
6
+
7
+package plan9
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
+}

+ 22
- 0
vendor/golang.org/x/sys/plan9/str.go View File

@@ -0,0 +1,22 @@
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 plan9
6
+
7
+package plan9
8
+
9
+func itoa(val int) string { // do it here rather than with fmt to avoid dependency
10
+	if val < 0 {
11
+		return "-" + itoa(-val)
12
+	}
13
+	var buf [32]byte // big enough for int64
14
+	i := len(buf) - 1
15
+	for val >= 10 {
16
+		buf[i] = byte(val%10 + '0')
17
+		i--
18
+		val /= 10
19
+	}
20
+	buf[i] = byte(val + '0')
21
+	return string(buf[i:])
22
+}

+ 74
- 0
vendor/golang.org/x/sys/plan9/syscall.go View File

@@ -0,0 +1,74 @@
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 plan9
6
+
7
+// Package plan9 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 the OS-specific documentation for the current
10
+// system.  If you want godoc to display 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.ErrorString.
22
+package plan9 // import "golang.org/x/sys/plan9"
23
+
24
+import "unsafe"
25
+
26
+// ByteSliceFromString returns a NUL-terminated slice of bytes
27
+// containing the text of s. If s contains a NUL byte at any
28
+// location, it returns (nil, EINVAL).
29
+func ByteSliceFromString(s string) ([]byte, error) {
30
+	for i := 0; i < len(s); i++ {
31
+		if s[i] == 0 {
32
+			return nil, EINVAL
33
+		}
34
+	}
35
+	a := make([]byte, len(s)+1)
36
+	copy(a, s)
37
+	return a, nil
38
+}
39
+
40
+// BytePtrFromString returns a pointer to a NUL-terminated array of
41
+// bytes containing the text of s. If s contains a NUL byte at any
42
+// location, it returns (nil, EINVAL).
43
+func BytePtrFromString(s string) (*byte, error) {
44
+	a, err := ByteSliceFromString(s)
45
+	if err != nil {
46
+		return nil, err
47
+	}
48
+	return &a[0], nil
49
+}
50
+
51
+// Single-word zero for use when we need a valid pointer to 0 bytes.
52
+// See mksyscall.pl.
53
+var _zero uintptr
54
+
55
+func (ts *Timespec) Unix() (sec int64, nsec int64) {
56
+	return int64(ts.Sec), int64(ts.Nsec)
57
+}
58
+
59
+func (tv *Timeval) Unix() (sec int64, nsec int64) {
60
+	return int64(tv.Sec), int64(tv.Usec) * 1000
61
+}
62
+
63
+func (ts *Timespec) Nano() int64 {
64
+	return int64(ts.Sec)*1e9 + int64(ts.Nsec)
65
+}
66
+
67
+func (tv *Timeval) Nano() int64 {
68
+	return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
69
+}
70
+
71
+// use is a no-op, but the compiler cannot see that it is.
72
+// Calling use(p) ensures that p is kept live until that point.
73
+//go:noescape
74
+func use(p unsafe.Pointer)

+ 349
- 0
vendor/golang.org/x/sys/plan9/syscall_plan9.go View File

@@ -0,0 +1,349 @@
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
+// Plan 9 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
10
+// wrap it in our own nicer implementation.
11
+
12
+package plan9
13
+
14
+import (
15
+	"syscall"
16
+	"unsafe"
17
+)
18
+
19
+// A Note is a string describing a process note.
20
+// It implements the os.Signal interface.
21
+type Note string
22
+
23
+func (n Note) Signal() {}
24
+
25
+func (n Note) String() string {
26
+	return string(n)
27
+}
28
+
29
+var (
30
+	Stdin  = 0
31
+	Stdout = 1
32
+	Stderr = 2
33
+)
34
+
35
+// For testing: clients can set this flag to force
36
+// creation of IPv6 sockets to return EAFNOSUPPORT.
37
+var SocketDisableIPv6 bool
38
+
39
+func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.ErrorString)
40
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.ErrorString)
41
+func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
42
+func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
43
+
44
+func atoi(b []byte) (n uint) {
45
+	n = 0
46
+	for i := 0; i < len(b); i++ {
47
+		n = n*10 + uint(b[i]-'0')
48
+	}
49
+	return
50
+}
51
+
52
+func cstring(s []byte) string {
53
+	for i := range s {
54
+		if s[i] == 0 {
55
+			return string(s[0:i])
56
+		}
57
+	}
58
+	return string(s)
59
+}
60
+
61
+func errstr() string {
62
+	var buf [ERRMAX]byte
63
+
64
+	RawSyscall(SYS_ERRSTR, uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf)), 0)
65
+
66
+	buf[len(buf)-1] = 0
67
+	return cstring(buf[:])
68
+}
69
+
70
+// Implemented in assembly to import from runtime.
71
+func exit(code int)
72
+
73
+func Exit(code int) { exit(code) }
74
+
75
+func readnum(path string) (uint, error) {
76
+	var b [12]byte
77
+
78
+	fd, e := Open(path, O_RDONLY)
79
+	if e != nil {
80
+		return 0, e
81
+	}
82
+	defer Close(fd)
83
+
84
+	n, e := Pread(fd, b[:], 0)
85
+
86
+	if e != nil {
87
+		return 0, e
88
+	}
89
+
90
+	m := 0
91
+	for ; m < n && b[m] == ' '; m++ {
92
+	}
93
+
94
+	return atoi(b[m : n-1]), nil
95
+}
96
+
97
+func Getpid() (pid int) {
98
+	n, _ := readnum("#c/pid")
99
+	return int(n)
100
+}
101
+
102
+func Getppid() (ppid int) {
103
+	n, _ := readnum("#c/ppid")
104
+	return int(n)
105
+}
106
+
107
+func Read(fd int, p []byte) (n int, err error) {
108
+	return Pread(fd, p, -1)
109
+}
110
+
111
+func Write(fd int, p []byte) (n int, err error) {
112
+	return Pwrite(fd, p, -1)
113
+}
114
+
115
+var ioSync int64
116
+
117
+//sys	fd2path(fd int, buf []byte) (err error)
118
+func Fd2path(fd int) (path string, err error) {
119
+	var buf [512]byte
120
+
121
+	e := fd2path(fd, buf[:])
122
+	if e != nil {
123
+		return "", e
124
+	}
125
+	return cstring(buf[:]), nil
126
+}
127
+
128
+//sys	pipe(p *[2]int32) (err error)
129
+func Pipe(p []int) (err error) {
130
+	if len(p) != 2 {
131
+		return syscall.ErrorString("bad arg in system call")
132
+	}
133
+	var pp [2]int32
134
+	err = pipe(&pp)
135
+	p[0] = int(pp[0])
136
+	p[1] = int(pp[1])
137
+	return
138
+}
139
+
140
+// Underlying system call writes to newoffset via pointer.
141
+// Implemented in assembly to avoid allocation.
142
+func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
143
+
144
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
145
+	newoffset, e := seek(0, fd, offset, whence)
146
+
147
+	if newoffset == -1 {
148
+		err = syscall.ErrorString(e)
149
+	}
150
+	return
151
+}
152
+
153
+func Mkdir(path string, mode uint32) (err error) {
154
+	fd, err := Create(path, O_RDONLY, DMDIR|mode)
155
+
156
+	if fd != -1 {
157
+		Close(fd)
158
+	}
159
+
160
+	return
161
+}
162
+
163
+type Waitmsg struct {
164
+	Pid  int
165
+	Time [3]uint32
166
+	Msg  string
167
+}
168
+
169
+func (w Waitmsg) Exited() bool   { return true }
170
+func (w Waitmsg) Signaled() bool { return false }
171
+
172
+func (w Waitmsg) ExitStatus() int {
173
+	if len(w.Msg) == 0 {
174
+		// a normal exit returns no message
175
+		return 0
176
+	}
177
+	return 1
178
+}
179
+
180
+//sys	await(s []byte) (n int, err error)
181
+func Await(w *Waitmsg) (err error) {
182
+	var buf [512]byte
183
+	var f [5][]byte
184
+
185
+	n, err := await(buf[:])
186
+
187
+	if err != nil || w == nil {
188
+		return
189
+	}
190
+
191
+	nf := 0
192
+	p := 0
193
+	for i := 0; i < n && nf < len(f)-1; i++ {
194
+		if buf[i] == ' ' {
195
+			f[nf] = buf[p:i]
196
+			p = i + 1
197
+			nf++
198
+		}
199
+	}
200
+	f[nf] = buf[p:]
201
+	nf++
202
+
203
+	if nf != len(f) {
204
+		return syscall.ErrorString("invalid wait message")
205
+	}
206
+	w.Pid = int(atoi(f[0]))
207
+	w.Time[0] = uint32(atoi(f[1]))
208
+	w.Time[1] = uint32(atoi(f[2]))
209
+	w.Time[2] = uint32(atoi(f[3]))
210
+	w.Msg = cstring(f[4])
211
+	if w.Msg == "''" {
212
+		// await() returns '' for no error
213
+		w.Msg = ""
214
+	}
215
+	return
216
+}
217
+
218
+func Unmount(name, old string) (err error) {
219
+	fixwd()
220
+	oldp, err := BytePtrFromString(old)
221
+	if err != nil {
222
+		return err
223
+	}
224
+	oldptr := uintptr(unsafe.Pointer(oldp))
225
+
226
+	var r0 uintptr
227
+	var e syscall.ErrorString
228
+
229
+	// bind(2) man page: If name is zero, everything bound or mounted upon old is unbound or unmounted.
230
+	if name == "" {
231
+		r0, _, e = Syscall(SYS_UNMOUNT, _zero, oldptr, 0)
232
+	} else {
233
+		namep, err := BytePtrFromString(name)
234
+		if err != nil {
235
+			return err
236
+		}
237
+		r0, _, e = Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(namep)), oldptr, 0)
238
+	}
239
+
240
+	if int32(r0) == -1 {
241
+		err = e
242
+	}
243
+	return
244
+}
245
+
246
+func Fchdir(fd int) (err error) {
247
+	path, err := Fd2path(fd)
248
+
249
+	if err != nil {
250
+		return
251
+	}
252
+
253
+	return Chdir(path)
254
+}
255
+
256
+type Timespec struct {
257
+	Sec  int32
258
+	Nsec int32
259
+}
260
+
261
+type Timeval struct {
262
+	Sec  int32
263
+	Usec int32
264
+}
265
+
266
+func NsecToTimeval(nsec int64) (tv Timeval) {
267
+	nsec += 999 // round up to microsecond
268
+	tv.Usec = int32(nsec % 1e9 / 1e3)
269
+	tv.Sec = int32(nsec / 1e9)
270
+	return
271
+}
272
+
273
+func nsec() int64 {
274
+	var scratch int64
275
+
276
+	r0, _, _ := Syscall(SYS_NSEC, uintptr(unsafe.Pointer(&scratch)), 0, 0)
277
+	// TODO(aram): remove hack after I fix _nsec in the pc64 kernel.
278
+	if r0 == 0 {
279
+		return scratch
280
+	}
281
+	return int64(r0)
282
+}
283
+
284
+func Gettimeofday(tv *Timeval) error {
285
+	nsec := nsec()
286
+	*tv = NsecToTimeval(nsec)
287
+	return nil
288
+}
289
+
290
+func Getpagesize() int { return 0x1000 }
291
+
292
+func Getegid() (egid int) { return -1 }
293
+func Geteuid() (euid int) { return -1 }
294
+func Getgid() (gid int)   { return -1 }
295
+func Getuid() (uid int)   { return -1 }
296
+
297
+func Getgroups() (gids []int, err error) {
298
+	return make([]int, 0), nil
299
+}
300
+
301
+//sys	open(path string, mode int) (fd int, err error)
302
+func Open(path string, mode int) (fd int, err error) {
303
+	fixwd()
304
+	return open(path, mode)
305
+}
306
+
307
+//sys	create(path string, mode int, perm uint32) (fd int, err error)
308
+func Create(path string, mode int, perm uint32) (fd int, err error) {
309
+	fixwd()
310
+	return create(path, mode, perm)
311
+}
312
+
313
+//sys	remove(path string) (err error)
314
+func Remove(path string) error {
315
+	fixwd()
316
+	return remove(path)
317
+}
318
+
319
+//sys	stat(path string, edir []byte) (n int, err error)
320
+func Stat(path string, edir []byte) (n int, err error) {
321
+	fixwd()
322
+	return stat(path, edir)
323
+}
324
+
325
+//sys	bind(name string, old string, flag int) (err error)
326
+func Bind(name string, old string, flag int) (err error) {
327
+	fixwd()
328
+	return bind(name, old, flag)
329
+}
330
+
331
+//sys	mount(fd int, afd int, old string, flag int, aname string) (err error)
332
+func Mount(fd int, afd int, old string, flag int, aname string) (err error) {
333
+	fixwd()
334
+	return mount(fd, afd, old, flag, aname)
335
+}
336
+
337
+//sys	wstat(path string, edir []byte) (err error)
338
+func Wstat(path string, edir []byte) (err error) {
339
+	fixwd()
340
+	return wstat(path, edir)
341
+}
342
+
343
+//sys	chdir(path string) (err error)
344
+//sys	Dup(oldfd int, newfd int) (fd int, err error)
345
+//sys	Pread(fd int, p []byte, offset int64) (n int, err error)
346
+//sys	Pwrite(fd int, p []byte, offset int64) (n int, err error)
347
+//sys	Close(fd int) (err error)
348
+//sys	Fstat(fd int, edir []byte) (n int, err error)
349
+//sys	Fwstat(fd int, edir []byte) (err error)

+ 33
- 0
vendor/golang.org/x/sys/plan9/syscall_test.go View File

@@ -0,0 +1,33 @@
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 plan9
6
+
7
+package plan9_test
8
+
9
+import (
10
+	"testing"
11
+
12
+	"golang.org/x/sys/plan9"
13
+)
14
+
15
+func testSetGetenv(t *testing.T, key, value string) {
16
+	err := plan9.Setenv(key, value)
17
+	if err != nil {
18
+		t.Fatalf("Setenv failed to set %q: %v", value, err)
19
+	}
20
+	newvalue, found := plan9.Getenv(key)
21
+	if !found {
22
+		t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
23
+	}
24
+	if newvalue != value {
25
+		t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value)
26
+	}
27
+}
28
+
29
+func TestEnv(t *testing.T) {
30
+	testSetGetenv(t, "TESTENV", "AVALUE")
31
+	// make sure TESTENV gets set to "", not deleted
32
+	testSetGetenv(t, "TESTENV", "")
33
+}

+ 292
- 0
vendor/golang.org/x/sys/plan9/zsyscall_plan9_386.go View File

@@ -0,0 +1,292 @@
1
+// mksyscall.pl -l32 -plan9 syscall_plan9.go
2
+// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
3
+
4
+package plan9
5
+
6
+import "unsafe"
7
+
8
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
9
+
10
+func fd2path(fd int, buf []byte) (err error) {
11
+	var _p0 unsafe.Pointer
12
+	if len(buf) > 0 {
13
+		_p0 = unsafe.Pointer(&buf[0])
14
+	} else {
15
+		_p0 = unsafe.Pointer(&_zero)
16
+	}
17
+	r0, _, e1 := Syscall(SYS_FD2PATH, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
18
+	if int32(r0) == -1 {
19
+		err = e1
20
+	}
21
+	return
22
+}
23
+
24
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
25
+
26
+func pipe(p *[2]int32) (err error) {
27
+	r0, _, e1 := Syscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
28
+	if int32(r0) == -1 {
29
+		err = e1
30
+	}
31
+	return
32
+}
33
+
34
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
35
+
36
+func await(s []byte) (n int, err error) {
37
+	var _p0 unsafe.Pointer
38
+	if len(s) > 0 {
39
+		_p0 = unsafe.Pointer(&s[0])
40
+	} else {
41
+		_p0 = unsafe.Pointer(&_zero)
42
+	}
43
+	r0, _, e1 := Syscall(SYS_AWAIT, uintptr(_p0), uintptr(len(s)), 0)
44
+	n = int(r0)
45
+	if int32(r0) == -1 {
46
+		err = e1
47
+	}
48
+	return
49
+}
50
+
51
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
52
+
53
+func open(path string, mode int) (fd int, err error) {
54
+	var _p0 *byte
55
+	_p0, err = BytePtrFromString(path)
56
+	if err != nil {
57
+		return
58
+	}
59
+	r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
60
+	use(unsafe.Pointer(_p0))
61
+	fd = int(r0)
62
+	if int32(r0) == -1 {
63
+		err = e1
64
+	}
65
+	return
66
+}
67
+
68
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
69
+
70
+func create(path string, mode int, perm uint32) (fd int, err error) {
71
+	var _p0 *byte
72
+	_p0, err = BytePtrFromString(path)
73
+	if err != nil {
74
+		return
75
+	}
76
+	r0, _, e1 := Syscall(SYS_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
77
+	use(unsafe.Pointer(_p0))
78
+	fd = int(r0)
79
+	if int32(r0) == -1 {
80
+		err = e1
81
+	}
82
+	return
83
+}
84
+
85
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
86
+
87
+func remove(path string) (err error) {
88
+	var _p0 *byte
89
+	_p0, err = BytePtrFromString(path)
90
+	if err != nil {
91
+		return
92
+	}
93
+	r0, _, e1 := Syscall(SYS_REMOVE, uintptr(unsafe.Pointer(_p0)), 0, 0)
94
+	use(unsafe.Pointer(_p0))
95
+	if int32(r0) == -1 {
96
+		err = e1
97
+	}
98
+	return
99
+}
100
+
101
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
102
+
103
+func stat(path string, edir []byte) (n int, err error) {
104
+	var _p0 *byte
105
+	_p0, err = BytePtrFromString(path)
106
+	if err != nil {
107
+		return
108
+	}
109
+	var _p1 unsafe.Pointer
110
+	if len(edir) > 0 {
111
+		_p1 = unsafe.Pointer(&edir[0])
112
+	} else {
113
+		_p1 = unsafe.Pointer(&_zero)
114
+	}
115
+	r0, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir)))
116
+	use(unsafe.Pointer(_p0))
117
+	n = int(r0)
118
+	if int32(r0) == -1 {
119
+		err = e1
120
+	}
121
+	return
122
+}
123
+
124
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
125
+
126
+func bind(name string, old string, flag int) (err error) {
127
+	var _p0 *byte
128
+	_p0, err = BytePtrFromString(name)
129
+	if err != nil {
130
+		return
131
+	}
132
+	var _p1 *byte
133
+	_p1, err = BytePtrFromString(old)
134
+	if err != nil {
135
+		return
136
+	}
137
+	r0, _, e1 := Syscall(SYS_BIND, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag))
138
+	use(unsafe.Pointer(_p0))
139
+	use(unsafe.Pointer(_p1))
140
+	if int32(r0) == -1 {
141
+		err = e1
142
+	}
143
+	return
144
+}
145
+
146
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
147
+
148
+func mount(fd int, afd int, old string, flag int, aname string) (err error) {
149
+	var _p0 *byte
150
+	_p0, err = BytePtrFromString(old)
151
+	if err != nil {
152
+		return
153
+	}
154
+	var _p1 *byte
155
+	_p1, err = BytePtrFromString(aname)
156
+	if err != nil {
157
+		return
158
+	}
159
+	r0, _, e1 := Syscall6(SYS_MOUNT, uintptr(fd), uintptr(afd), uintptr(unsafe.Pointer(_p0)), uintptr(flag), uintptr(unsafe.Pointer(_p1)), 0)
160
+	use(unsafe.Pointer(_p0))
161
+	use(unsafe.Pointer(_p1))
162
+	if int32(r0) == -1 {
163
+		err = e1
164
+	}
165
+	return
166
+}
167
+
168
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
169
+
170
+func wstat(path string, edir []byte) (err error) {
171
+	var _p0 *byte
172
+	_p0, err = BytePtrFromString(path)
173
+	if err != nil {
174
+		return
175
+	}
176
+	var _p1 unsafe.Pointer
177
+	if len(edir) > 0 {
178
+		_p1 = unsafe.Pointer(&edir[0])
179
+	} else {
180
+		_p1 = unsafe.Pointer(&_zero)
181
+	}
182
+	r0, _, e1 := Syscall(SYS_WSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir)))
183
+	use(unsafe.Pointer(_p0))
184
+	if int32(r0) == -1 {
185
+		err = e1
186
+	}
187
+	return
188
+}
189
+
190
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
191
+
192
+func chdir(path string) (err error) {
193
+	var _p0 *byte
194
+	_p0, err = BytePtrFromString(path)
195
+	if err != nil {
196
+		return
197
+	}
198
+	r0, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
199
+	use(unsafe.Pointer(_p0))
200
+	if int32(r0) == -1 {
201
+		err = e1
202
+	}
203
+	return
204
+}
205
+
206
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
207
+
208
+func Dup(oldfd int, newfd int) (fd int, err error) {
209
+	r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), uintptr(newfd), 0)
210
+	fd = int(r0)
211
+	if int32(r0) == -1 {
212
+		err = e1
213
+	}
214
+	return
215
+}
216
+
217
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
218
+
219
+func Pread(fd int, p []byte, offset int64) (n int, err error) {
220
+	var _p0 unsafe.Pointer
221
+	if len(p) > 0 {
222
+		_p0 = unsafe.Pointer(&p[0])
223
+	} else {
224
+		_p0 = unsafe.Pointer(&_zero)
225
+	}
226
+	r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
227
+	n = int(r0)
228
+	if int32(r0) == -1 {
229
+		err = e1
230
+	}
231
+	return
232
+}
233
+
234
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
235
+
236
+func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
237
+	var _p0 unsafe.Pointer
238
+	if len(p) > 0 {
239
+		_p0 = unsafe.Pointer(&p[0])
240
+	} else {
241
+		_p0 = unsafe.Pointer(&_zero)
242
+	}
243
+	r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
244
+	n = int(r0)
245
+	if int32(r0) == -1 {
246
+		err = e1
247
+	}
248
+	return
249
+}
250
+
251
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
252
+
253
+func Close(fd int) (err error) {
254
+	r0, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
255
+	if int32(r0) == -1 {
256
+		err = e1
257
+	}
258
+	return
259
+}
260
+
261
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
262
+
263
+func Fstat(fd int, edir []byte) (n int, err error) {
264
+	var _p0 unsafe.Pointer
265
+	if len(edir) > 0 {
266
+		_p0 = unsafe.Pointer(&edir[0])
267
+	} else {
268
+		_p0 = unsafe.Pointer(&_zero)
269
+	}
270
+	r0, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir)))
271
+	n = int(r0)
272
+	if int32(r0) == -1 {
273
+		err = e1
274
+	}
275
+	return
276
+}
277
+
278
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
279
+
280
+func Fwstat(fd int, edir []byte) (err error) {
281
+	var _p0 unsafe.Pointer
282
+	if len(edir) > 0 {
283
+		_p0 = unsafe.Pointer(&edir[0])
284
+	} else {
285
+		_p0 = unsafe.Pointer(&_zero)
286
+	}
287
+	r0, _, e1 := Syscall(SYS_FWSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir)))
288
+	if int32(r0) == -1 {
289
+		err = e1
290
+	}
291
+	return
292
+}

+ 292
- 0
vendor/golang.org/x/sys/plan9/zsyscall_plan9_amd64.go View File

@@ -0,0 +1,292 @@
1
+// mksyscall.pl -l32 -plan9 syscall_plan9.go
2
+// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
3
+
4
+package plan9
5
+
6
+import "unsafe"
7
+
8
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
9
+
10
+func fd2path(fd int, buf []byte) (err error) {
11
+	var _p0 unsafe.Pointer
12
+	if len(buf) > 0 {
13
+		_p0 = unsafe.Pointer(&buf[0])
14
+	} else {
15
+		_p0 = unsafe.Pointer(&_zero)
16
+	}
17
+	r0, _, e1 := Syscall(SYS_FD2PATH, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
18
+	if int32(r0) == -1 {
19
+		err = e1
20
+	}
21
+	return
22
+}
23
+
24
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
25
+
26
+func pipe(p *[2]int32) (err error) {
27
+	r0, _, e1 := Syscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
28
+	if int32(r0) == -1 {
29
+		err = e1
30
+	}
31
+	return
32
+}
33
+
34
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
35
+
36
+func await(s []byte) (n int, err error) {
37
+	var _p0 unsafe.Pointer
38
+	if len(s) > 0 {
39
+		_p0 = unsafe.Pointer(&s[0])
40
+	} else {
41
+		_p0 = unsafe.Pointer(&_zero)
42
+	}
43
+	r0, _, e1 := Syscall(SYS_AWAIT, uintptr(_p0), uintptr(len(s)), 0)
44
+	n = int(r0)
45
+	if int32(r0) == -1 {
46
+		err = e1
47
+	}
48
+	return
49
+}
50
+
51
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
52
+
53
+func open(path string, mode int) (fd int, err error) {
54
+	var _p0 *byte
55
+	_p0, err = BytePtrFromString(path)
56
+	if err != nil {
57
+		return
58
+	}
59
+	r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
60
+	use(unsafe.Pointer(_p0))
61
+	fd = int(r0)
62
+	if int32(r0) == -1 {
63
+		err = e1
64
+	}
65
+	return
66
+}
67
+
68
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
69
+
70
+func create(path string, mode int, perm uint32) (fd int, err error) {
71
+	var _p0 *byte
72
+	_p0, err = BytePtrFromString(path)
73
+	if err != nil {
74
+		return
75
+	}
76
+	r0, _, e1 := Syscall(SYS_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
77
+	use(unsafe.Pointer(_p0))
78
+	fd = int(r0)
79
+	if int32(r0) == -1 {
80
+		err = e1
81
+	}
82
+	return
83
+}
84
+
85
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
86
+
87
+func remove(path string) (err error) {
88
+	var _p0 *byte
89
+	_p0, err = BytePtrFromString(path)
90
+	if err != nil {
91
+		return
92
+	}
93
+	r0, _, e1 := Syscall(SYS_REMOVE, uintptr(unsafe.Pointer(_p0)), 0, 0)
94
+	use(unsafe.Pointer(_p0))
95
+	if int32(r0) == -1 {
96
+		err = e1
97
+	}
98
+	return
99
+}
100
+
101
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
102
+
103
+func stat(path string, edir []byte) (n int, err error) {
104
+	var _p0 *byte
105
+	_p0, err = BytePtrFromString(path)
106
+	if err != nil {
107
+		return
108
+	}
109
+	var _p1 unsafe.Pointer
110
+	if len(edir) > 0 {
111
+		_p1 = unsafe.Pointer(&edir[0])
112
+	} else {
113
+		_p1 = unsafe.Pointer(&_zero)
114
+	}
115
+	r0, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir)))
116
+	use(unsafe.Pointer(_p0))
117
+	n = int(r0)
118
+	if int32(r0) == -1 {
119
+		err = e1
120
+	}
121
+	return
122
+}
123
+
124
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
125
+
126
+func bind(name string, old string, flag int) (err error) {
127
+	var _p0 *byte
128
+	_p0, err = BytePtrFromString(name)
129
+	if err != nil {
130
+		return
131
+	}
132
+	var _p1 *byte
133
+	_p1, err = BytePtrFromString(old)
134
+	if err != nil {
135
+		return
136
+	}
137
+	r0, _, e1 := Syscall(SYS_BIND, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag))
138
+	use(unsafe.Pointer(_p0))
139
+	use(unsafe.Pointer(_p1))
140
+	if int32(r0) == -1 {
141
+		err = e1
142
+	}
143
+	return
144
+}
145
+
146
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
147
+
148
+func mount(fd int, afd int, old string, flag int, aname string) (err error) {
149
+	var _p0 *byte
150
+	_p0, err = BytePtrFromString(old)
151
+	if err != nil {
152
+		return
153
+	}
154
+	var _p1 *byte
155
+	_p1, err = BytePtrFromString(aname)
156
+	if err != nil {
157
+		return
158
+	}
159
+	r0, _, e1 := Syscall6(SYS_MOUNT, uintptr(fd), uintptr(afd), uintptr(unsafe.Pointer(_p0)), uintptr(flag), uintptr(unsafe.Pointer(_p1)), 0)
160
+	use(unsafe.Pointer(_p0))
161
+	use(unsafe.Pointer(_p1))
162
+	if int32(r0) == -1 {
163
+		err = e1
164
+	}
165
+	return
166
+}
167
+
168
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
169
+
170
+func wstat(path string, edir []byte) (err error) {
171
+	var _p0 *byte
172
+	_p0, err = BytePtrFromString(path)
173
+	if err != nil {
174
+		return
175
+	}
176
+	var _p1 unsafe.Pointer
177
+	if len(edir) > 0 {
178
+		_p1 = unsafe.Pointer(&edir[0])
179
+	} else {
180
+		_p1 = unsafe.Pointer(&_zero)
181
+	}
182
+	r0, _, e1 := Syscall(SYS_WSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir)))
183
+	use(unsafe.Pointer(_p0))
184
+	if int32(r0) == -1 {
185
+		err = e1
186
+	}
187
+	return
188
+}
189
+
190
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
191
+
192
+func chdir(path string) (err error) {
193
+	var _p0 *byte
194
+	_p0, err = BytePtrFromString(path)
195
+	if err != nil {
196
+		return
197
+	}
198
+	r0, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
199
+	use(unsafe.Pointer(_p0))
200
+	if int32(r0) == -1 {
201
+		err = e1
202
+	}
203
+	return
204
+}
205
+
206
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
207
+
208
+func Dup(oldfd int, newfd int) (fd int, err error) {
209
+	r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), uintptr(newfd), 0)
210
+	fd = int(r0)
211
+	if int32(r0) == -1 {
212
+		err = e1
213
+	}
214
+	return
215
+}
216
+
217
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
218
+
219
+func Pread(fd int, p []byte, offset int64) (n int, err error) {
220
+	var _p0 unsafe.Pointer
221
+	if len(p) > 0 {
222
+		_p0 = unsafe.Pointer(&p[0])
223
+	} else {
224
+		_p0 = unsafe.Pointer(&_zero)
225
+	}
226
+	r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
227
+	n = int(r0)
228
+	if int32(r0) == -1 {
229
+		err = e1
230
+	}
231
+	return
232
+}
233
+
234
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
235
+
236
+func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
237
+	var _p0 unsafe.Pointer
238
+	if len(p) > 0 {
239
+		_p0 = unsafe.Pointer(&p[0])
240
+	} else {
241
+		_p0 = unsafe.Pointer(&_zero)
242
+	}
243
+	r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
244
+	n = int(r0)
245
+	if int32(r0) == -1 {
246
+		err = e1
247
+	}
248
+	return
249
+}
250
+
251
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
252
+
253
+func Close(fd int) (err error) {
254
+	r0, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
255
+	if int32(r0) == -1 {
256
+		err = e1
257
+	}
258
+	return
259
+}
260
+
261
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
262
+
263
+func Fstat(fd int, edir []byte) (n int, err error) {
264
+	var _p0 unsafe.Pointer
265
+	if len(edir) > 0 {
266
+		_p0 = unsafe.Pointer(&edir[0])
267
+	} else {
268
+		_p0 = unsafe.Pointer(&_zero)
269
+	}
270
+	r0, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir)))
271
+	n = int(r0)
272
+	if int32(r0) == -1 {
273
+		err = e1
274
+	}
275
+	return
276
+}
277
+
278
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
279
+
280
+func Fwstat(fd int, edir []byte) (err error) {
281
+	var _p0 unsafe.Pointer
282
+	if len(edir) > 0 {
283
+		_p0 = unsafe.Pointer(&edir[0])
284
+	} else {
285
+		_p0 = unsafe.Pointer(&_zero)
286
+	}
287
+	r0, _, e1 := Syscall(SYS_FWSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir)))
288
+	if int32(r0) == -1 {
289
+		err = e1
290
+	}
291
+	return
292
+}

+ 49
- 0
vendor/golang.org/x/sys/plan9/zsysnum_plan9.go View File

@@ -0,0 +1,49 @@
1
+// mksysnum_plan9.sh /opt/plan9/sys/src/libc/9syscall/sys.h
2
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
3
+
4
+package plan9
5
+
6
+const (
7
+	SYS_SYSR1       = 0
8
+	SYS_BIND        = 2
9
+	SYS_CHDIR       = 3
10
+	SYS_CLOSE       = 4
11
+	SYS_DUP         = 5
12
+	SYS_ALARM       = 6
13
+	SYS_EXEC        = 7
14
+	SYS_EXITS       = 8
15
+	SYS_FAUTH       = 10
16
+	SYS_SEGBRK      = 12
17
+	SYS_OPEN        = 14
18
+	SYS_OSEEK       = 16
19
+	SYS_SLEEP       = 17
20
+	SYS_RFORK       = 19
21
+	SYS_PIPE        = 21
22
+	SYS_CREATE      = 22
23
+	SYS_FD2PATH     = 23
24
+	SYS_BRK_        = 24
25
+	SYS_REMOVE      = 25
26
+	SYS_NOTIFY      = 28
27
+	SYS_NOTED       = 29
28
+	SYS_SEGATTACH   = 30
29
+	SYS_SEGDETACH   = 31
30
+	SYS_SEGFREE     = 32
31
+	SYS_SEGFLUSH    = 33
32
+	SYS_RENDEZVOUS  = 34
33
+	SYS_UNMOUNT     = 35
34
+	SYS_SEMACQUIRE  = 37
35
+	SYS_SEMRELEASE  = 38
36
+	SYS_SEEK        = 39
37
+	SYS_FVERSION    = 40
38
+	SYS_ERRSTR      = 41
39
+	SYS_STAT        = 42
40
+	SYS_FSTAT       = 43
41
+	SYS_WSTAT       = 44
42
+	SYS_FWSTAT      = 45
43
+	SYS_MOUNT       = 46
44
+	SYS_AWAIT       = 47
45
+	SYS_PREAD       = 50
46
+	SYS_PWRITE      = 51
47
+	SYS_TSEMACQUIRE = 52
48
+	SYS_NSEC        = 53
49
+)

+ 1
- 0
vendor/golang.org/x/sys/unix/.gitignore View File

@@ -0,0 +1 @@
1
+_obj/

+ 173
- 0
vendor/golang.org/x/sys/unix/README.md View File

@@ -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/golang.org/x/sys/unix/asm_darwin_386.s View File

@@ -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/golang.org/x/sys/unix/asm_darwin_amd64.s View File

@@ -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/golang.org/x/sys/unix/asm_darwin_arm.s View File

@@ -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/golang.org/x/sys/unix/asm_darwin_arm64.s View File

@@ -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/golang.org/x/sys/unix/asm_dragonfly_amd64.s View File

@@ -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/golang.org/x/sys/unix/asm_freebsd_386.s View File

@@ -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/golang.org/x/sys/unix/asm_freebsd_amd64.s View File

@@ -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/golang.org/x/sys/unix/asm_freebsd_arm.s View File

@@ -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/golang.org/x/sys/unix/asm_linux_386.s View File

@@ -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/golang.org/x/sys/unix/asm_linux_amd64.s View File

@@ -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/golang.org/x/sys/unix/asm_linux_arm.s View File

@@ -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/golang.org/x/sys/unix/asm_linux_arm64.s View File

@@ -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/golang.org/x/sys/unix/asm_linux_mips64x.s View File

@@ -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/golang.org/x/sys/unix/asm_linux_mipsx.s View File

@@ -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/golang.org/x/sys/unix/asm_linux_ppc64x.s View File

@@ -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/golang.org/x/sys/unix/asm_linux_s390x.s View File

@@ -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/golang.org/x/sys/unix/asm_netbsd_386.s View File

@@ -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/golang.org/x/sys/unix/asm_netbsd_amd64.s View File

@@ -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/golang.org/x/sys/unix/asm_netbsd_arm.s View File

@@ -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/golang.org/x/sys/unix/asm_openbsd_386.s View File

@@ -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/golang.org/x/sys/unix/asm_openbsd_amd64.s View File

@@ -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)

+ 17
- 0
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s View File

@@ -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/golang.org/x/sys/unix/bluetooth_linux.go View File

@@ -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
+)

+ 13
- 0
vendor/golang.org/x/sys/unix/constants.go View File

@@ -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
+)

+ 121
- 0
vendor/golang.org/x/sys/unix/creds_test.go View File

@@ -0,0 +1,121 @@
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
+	fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_STREAM, 0)
25
+	if err != nil {
26
+		t.Fatalf("Socketpair: %v", err)
27
+	}
28
+	defer unix.Close(fds[0])
29
+	defer unix.Close(fds[1])
30
+
31
+	err = unix.SetsockoptInt(fds[0], unix.SOL_SOCKET, unix.SO_PASSCRED, 1)
32
+	if err != nil {
33
+		t.Fatalf("SetsockoptInt: %v", err)
34
+	}
35
+
36
+	srvFile := os.NewFile(uintptr(fds[0]), "server")
37
+	defer srvFile.Close()
38
+	srv, err := net.FileConn(srvFile)
39
+	if err != nil {
40
+		t.Errorf("FileConn: %v", err)
41
+		return
42
+	}
43
+	defer srv.Close()
44
+
45
+	cliFile := os.NewFile(uintptr(fds[1]), "client")
46
+	defer cliFile.Close()
47
+	cli, err := net.FileConn(cliFile)
48
+	if err != nil {
49
+		t.Errorf("FileConn: %v", err)
50
+		return
51
+	}
52
+	defer cli.Close()
53
+
54
+	var ucred unix.Ucred
55
+	if os.Getuid() != 0 {
56
+		ucred.Pid = int32(os.Getpid())
57
+		ucred.Uid = 0
58
+		ucred.Gid = 0
59
+		oob := unix.UnixCredentials(&ucred)
60
+		_, _, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil)
61
+		if op, ok := err.(*net.OpError); ok {
62
+			err = op.Err
63
+		}
64
+		if sys, ok := err.(*os.SyscallError); ok {
65
+			err = sys.Err
66
+		}
67
+		if err != syscall.EPERM {
68
+			t.Fatalf("WriteMsgUnix failed with %v, want EPERM", err)
69
+		}
70
+	}
71
+
72
+	ucred.Pid = int32(os.Getpid())
73
+	ucred.Uid = uint32(os.Getuid())
74
+	ucred.Gid = uint32(os.Getgid())
75
+	oob := unix.UnixCredentials(&ucred)
76
+
77
+	// this is going to send a dummy byte
78
+	n, oobn, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil)
79
+	if err != nil {
80
+		t.Fatalf("WriteMsgUnix: %v", err)
81
+	}
82
+	if n != 0 {
83
+		t.Fatalf("WriteMsgUnix n = %d, want 0", n)
84
+	}
85
+	if oobn != len(oob) {
86
+		t.Fatalf("WriteMsgUnix oobn = %d, want %d", oobn, len(oob))
87
+	}
88
+
89
+	oob2 := make([]byte, 10*len(oob))
90
+	n, oobn2, flags, _, err := srv.(*net.UnixConn).ReadMsgUnix(nil, oob2)
91
+	if err != nil {
92
+		t.Fatalf("ReadMsgUnix: %v", err)
93
+	}
94
+	if flags != 0 {
95
+		t.Fatalf("ReadMsgUnix flags = 0x%x, want 0", flags)
96
+	}
97
+	if n != 1 {
98
+		t.Fatalf("ReadMsgUnix n = %d, want 1 (dummy byte)", n)
99
+	}
100
+	if oobn2 != oobn {
101
+		// without SO_PASSCRED set on the socket, ReadMsgUnix will
102
+		// return zero oob bytes
103
+		t.Fatalf("ReadMsgUnix oobn = %d, want %d", oobn2, oobn)
104
+	}
105
+	oob2 = oob2[:oobn2]
106
+	if !bytes.Equal(oob, oob2) {
107
+		t.Fatal("ReadMsgUnix oob bytes don't match")
108
+	}
109
+
110
+	scm, err := unix.ParseSocketControlMessage(oob2)
111
+	if err != nil {
112
+		t.Fatalf("ParseSocketControlMessage: %v", err)
113
+	}
114
+	newUcred, err := unix.ParseUnixCredentials(&scm[0])
115
+	if err != nil {
116
+		t.Fatalf("ParseUnixCredentials: %v", err)
117
+	}
118
+	if *newUcred != ucred {
119
+		t.Fatalf("ParseUnixCredentials = %+v, want %+v", newUcred, ucred)
120
+	}
121
+}

+ 102
- 0
vendor/golang.org/x/sys/unix/dirent.go View File

@@ -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/golang.org/x/sys/unix/endian_big.go View File

@@ -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/golang.org/x/sys/unix/endian_little.go View File

@@ -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/golang.org/x/sys/unix/env_unix.go View File

@@ -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/golang.org/x/sys/unix/env_unset.go View File

@@ -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
+}

+ 9
- 0
vendor/golang.org/x/sys/unix/export_test.go View File

@@ -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

+ 24
- 0
vendor/golang.org/x/sys/unix/flock.go View File

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

+ 13
- 0
vendor/golang.org/x/sys/unix/flock_linux_32bit.go View File

@@ -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/golang.org/x/sys/unix/gccgo.go View File

@@ -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/golang.org/x/sys/unix/gccgo_c.c View File

@@ -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/golang.org/x/sys/unix/gccgo_linux_amd64.go View File

@@ -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
+}

+ 20
- 0
vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go View File

@@ -0,0 +1,20 @@
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 gccgo,linux,sparc64
6
+
7
+package unix
8
+
9
+import "syscall"
10
+
11
+//extern sysconf
12
+func realSysconf(name int) int64
13
+
14
+func sysconf(name int) (n int64, err syscall.Errno) {
15
+	r := realSysconf(name)
16
+	if r < 0 {
17
+		return 0, syscall.GetErrno()
18
+	}
19
+	return r, 0
20
+}

+ 0
- 0
vendor/golang.org/x/sys/unix/linux/Dockerfile View File


Some files were not shown because too many files changed in this diff