mirror of
https://github.com/go-task/task.git
synced 2025-06-23 00:38:19 +02:00
update dependencies
- add watch - remove fsnotify - update others
This commit is contained in:
26
Gopkg.lock
generated
26
Gopkg.lock
generated
@ -25,12 +25,6 @@
|
|||||||
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
|
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
|
||||||
version = "v1.1.0"
|
version = "v1.1.0"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
name = "github.com/fsnotify/fsnotify"
|
|
||||||
packages = ["."]
|
|
||||||
revision = "4da3e2cfbabc9f751898f250b49f2439785783a1"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/huandu/xstrings"
|
name = "github.com/huandu/xstrings"
|
||||||
@ -50,10 +44,10 @@
|
|||||||
revision = "95345c4e1c0ebc9d16a3284177f09360f4d20fab"
|
revision = "95345c4e1c0ebc9d16a3284177f09360f4d20fab"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
name = "github.com/mvdan/sh"
|
name = "github.com/mvdan/sh"
|
||||||
packages = ["interp","syntax"]
|
packages = ["interp","syntax"]
|
||||||
revision = "e5b6ba788962dcccf0a5a50723f5b35623f16e18"
|
revision = "e6f9238b1f62400b3834f893a4f0088353519e82"
|
||||||
version = "v2.0-beta1"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/pmezard/go-difflib"
|
name = "github.com/pmezard/go-difflib"
|
||||||
@ -61,6 +55,12 @@
|
|||||||
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
|
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
|
||||||
version = "v1.0.0"
|
version = "v1.0.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/radovskyb/watcher"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "005eaf39e854c7af9082e63e9df884ad840819c8"
|
||||||
|
version = "v1.0.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/satori/go.uuid"
|
name = "github.com/satori/go.uuid"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
@ -83,7 +83,7 @@
|
|||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/crypto"
|
name = "golang.org/x/crypto"
|
||||||
packages = ["pbkdf2","scrypt"]
|
packages = ["pbkdf2","scrypt"]
|
||||||
revision = "558b6879de74bc843225cde5686419267ff707ca"
|
revision = "42ff06aea7c329876e5a0fe94acc96902accf0ad"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
@ -97,12 +97,6 @@
|
|||||||
packages = ["errgroup"]
|
packages = ["errgroup"]
|
||||||
revision = "f52d1811a62927559de87708c8913c1650ce4f26"
|
revision = "f52d1811a62927559de87708c8913c1650ce4f26"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
name = "golang.org/x/sys"
|
|
||||||
packages = ["unix"]
|
|
||||||
revision = "0f826bdd13b500be0f1d4004938ad978fcc6031e"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "v2"
|
branch = "v2"
|
||||||
name = "gopkg.in/yaml.v2"
|
name = "gopkg.in/yaml.v2"
|
||||||
@ -112,6 +106,6 @@
|
|||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "93839de063626661a216a313ab71e2ad920afb2528f69ca6110c2155276e6dab"
|
inputs-digest = "e4d557aa8ac5361b90bedf938605af1892ee59538b0770cd416aad772e57e343"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
@ -70,10 +70,6 @@
|
|||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/Masterminds/sprig"
|
name = "github.com/Masterminds/sprig"
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
branch = "master"
|
|
||||||
name = "github.com/fsnotify/fsnotify"
|
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/imdario/mergo"
|
name = "github.com/imdario/mergo"
|
||||||
@ -97,3 +93,7 @@
|
|||||||
[[constraint]]
|
[[constraint]]
|
||||||
branch = "v2"
|
branch = "v2"
|
||||||
name = "gopkg.in/yaml.v2"
|
name = "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/radovskyb/watcher"
|
||||||
|
5
vendor/github.com/fsnotify/fsnotify/.editorconfig
generated
vendored
5
vendor/github.com/fsnotify/fsnotify/.editorconfig
generated
vendored
@ -1,5 +0,0 @@
|
|||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
indent_style = tab
|
|
||||||
indent_size = 4
|
|
6
vendor/github.com/fsnotify/fsnotify/.gitignore
generated
vendored
6
vendor/github.com/fsnotify/fsnotify/.gitignore
generated
vendored
@ -1,6 +0,0 @@
|
|||||||
# Setup a Global .gitignore for OS and editor generated files:
|
|
||||||
# https://help.github.com/articles/ignoring-files
|
|
||||||
# git config --global core.excludesfile ~/.gitignore_global
|
|
||||||
|
|
||||||
.vagrant
|
|
||||||
*.sublime-project
|
|
30
vendor/github.com/fsnotify/fsnotify/.travis.yml
generated
vendored
30
vendor/github.com/fsnotify/fsnotify/.travis.yml
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
sudo: false
|
|
||||||
language: go
|
|
||||||
|
|
||||||
go:
|
|
||||||
- 1.8
|
|
||||||
- 1.7.x
|
|
||||||
- tip
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- go: tip
|
|
||||||
fast_finish: true
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- go get -u github.com/golang/lint/golint
|
|
||||||
|
|
||||||
script:
|
|
||||||
- go test -v --race ./...
|
|
||||||
|
|
||||||
after_script:
|
|
||||||
- test -z "$(gofmt -s -l -w . | tee /dev/stderr)"
|
|
||||||
- test -z "$(golint ./... | tee /dev/stderr)"
|
|
||||||
- go vet ./...
|
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
46
vendor/github.com/fsnotify/fsnotify/AUTHORS
generated
vendored
46
vendor/github.com/fsnotify/fsnotify/AUTHORS
generated
vendored
@ -1,46 +0,0 @@
|
|||||||
# Names should be added to this file as
|
|
||||||
# Name or Organization <email address>
|
|
||||||
# The email address is not required for organizations.
|
|
||||||
|
|
||||||
# You can update this list using the following command:
|
|
||||||
#
|
|
||||||
# $ git shortlog -se | awk '{print $2 " " $3 " " $4}'
|
|
||||||
|
|
||||||
# Please keep the list sorted.
|
|
||||||
|
|
||||||
Adrien Bustany <adrien@bustany.org>
|
|
||||||
Amit Krishnan <amit.krishnan@oracle.com>
|
|
||||||
Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
|
|
||||||
Bruno Bigras <bigras.bruno@gmail.com>
|
|
||||||
Caleb Spare <cespare@gmail.com>
|
|
||||||
Case Nelson <case@teammating.com>
|
|
||||||
Chris Howey <chris@howey.me> <howeyc@gmail.com>
|
|
||||||
Christoffer Buchholz <christoffer.buchholz@gmail.com>
|
|
||||||
Daniel Wagner-Hall <dawagner@gmail.com>
|
|
||||||
Dave Cheney <dave@cheney.net>
|
|
||||||
Evan Phoenix <evan@fallingsnow.net>
|
|
||||||
Francisco Souza <f@souza.cc>
|
|
||||||
Hari haran <hariharan.uno@gmail.com>
|
|
||||||
John C Barstow
|
|
||||||
Kelvin Fo <vmirage@gmail.com>
|
|
||||||
Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>
|
|
||||||
Matt Layher <mdlayher@gmail.com>
|
|
||||||
Nathan Youngman <git@nathany.com>
|
|
||||||
Patrick <patrick@dropbox.com>
|
|
||||||
Paul Hammond <paul@paulhammond.org>
|
|
||||||
Pawel Knap <pawelknap88@gmail.com>
|
|
||||||
Pieter Droogendijk <pieter@binky.org.uk>
|
|
||||||
Pursuit92 <JoshChase@techpursuit.net>
|
|
||||||
Riku Voipio <riku.voipio@linaro.org>
|
|
||||||
Rob Figueiredo <robfig@gmail.com>
|
|
||||||
Slawek Ligus <root@ooz.ie>
|
|
||||||
Soge Zhang <zhssoge@gmail.com>
|
|
||||||
Tiffany Jernigan <tiffany.jernigan@intel.com>
|
|
||||||
Tilak Sharma <tilaks@google.com>
|
|
||||||
Travis Cline <travis.cline@gmail.com>
|
|
||||||
Tudor Golubenco <tudor.g@gmail.com>
|
|
||||||
Yukang <moorekang@gmail.com>
|
|
||||||
bronze1man <bronze1man@gmail.com>
|
|
||||||
debrando <denis.brandolini@gmail.com>
|
|
||||||
henrikedwards <henrik.edwards@gmail.com>
|
|
||||||
铁哥 <guotie.9@gmail.com>
|
|
307
vendor/github.com/fsnotify/fsnotify/CHANGELOG.md
generated
vendored
307
vendor/github.com/fsnotify/fsnotify/CHANGELOG.md
generated
vendored
@ -1,307 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
## v1.4.2 / 2016-10-10
|
|
||||||
|
|
||||||
* 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)
|
|
||||||
|
|
||||||
## v1.4.1 / 2016-10-04
|
|
||||||
|
|
||||||
* Fix flaky inotify stress test on Linux [#177](https://github.com/fsnotify/fsnotify/pull/177) (thanks @pattyshack)
|
|
||||||
|
|
||||||
## v1.4.0 / 2016-10-01
|
|
||||||
|
|
||||||
* add a String() method to Event.Op [#165](https://github.com/fsnotify/fsnotify/pull/165) (thanks @oozie)
|
|
||||||
|
|
||||||
## v1.3.1 / 2016-06-28
|
|
||||||
|
|
||||||
* Windows: fix for double backslash when watching the root of a drive [#151](https://github.com/fsnotify/fsnotify/issues/151) (thanks @brunoqc)
|
|
||||||
|
|
||||||
## v1.3.0 / 2016-04-19
|
|
||||||
|
|
||||||
* 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)
|
|
||||||
|
|
||||||
## v1.2.10 / 2016-03-02
|
|
||||||
|
|
||||||
* Fix golint errors in windows.go [#121](https://github.com/fsnotify/fsnotify/pull/121) (thanks @tiffanyfj)
|
|
||||||
|
|
||||||
## v1.2.9 / 2016-01-13
|
|
||||||
|
|
||||||
kqueue: Fix logic for CREATE after REMOVE [#111](https://github.com/fsnotify/fsnotify/pull/111) (thanks @bep)
|
|
||||||
|
|
||||||
## v1.2.8 / 2015-12-17
|
|
||||||
|
|
||||||
* 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)
|
|
||||||
* inotify: fix race in test
|
|
||||||
* enable race detection for continuous integration (Linux, Mac, Windows)
|
|
||||||
|
|
||||||
## v1.2.5 / 2015-10-17
|
|
||||||
|
|
||||||
* inotify: use epoll_create1 for arm64 support (requires Linux 2.6.27 or later) [#100](https://github.com/fsnotify/fsnotify/pull/100) (thanks @suihkulokki)
|
|
||||||
* inotify: fix path leaks [#73](https://github.com/fsnotify/fsnotify/pull/73) (thanks @chamaken)
|
|
||||||
* kqueue: watch for rename events on subdirectories [#83](https://github.com/fsnotify/fsnotify/pull/83) (thanks @guotie)
|
|
||||||
* kqueue: avoid infinite loops from symlinks cycles [#101](https://github.com/fsnotify/fsnotify/pull/101) (thanks @illicitonion)
|
|
||||||
|
|
||||||
## v1.2.1 / 2015-10-14
|
|
||||||
|
|
||||||
* kqueue: don't watch named pipes [#98](https://github.com/fsnotify/fsnotify/pull/98) (thanks @evanphx)
|
|
||||||
|
|
||||||
## v1.2.0 / 2015-02-08
|
|
||||||
|
|
||||||
* inotify: use epoll to wake up readEvents [#66](https://github.com/fsnotify/fsnotify/pull/66) (thanks @PieterD)
|
|
||||||
* inotify: closing watcher should now always shut down goroutine [#63](https://github.com/fsnotify/fsnotify/pull/63) (thanks @PieterD)
|
|
||||||
* kqueue: close kqueue after removing watches, fixes [#59](https://github.com/fsnotify/fsnotify/issues/59)
|
|
||||||
|
|
||||||
## v1.1.1 / 2015-02-05
|
|
||||||
|
|
||||||
* inotify: Retry read on EINTR [#61](https://github.com/fsnotify/fsnotify/issues/61) (thanks @PieterD)
|
|
||||||
|
|
||||||
## v1.1.0 / 2014-12-12
|
|
||||||
|
|
||||||
* kqueue: rework internals [#43](https://github.com/fsnotify/fsnotify/pull/43)
|
|
||||||
* add low-level functions
|
|
||||||
* only need to store flags on directories
|
|
||||||
* less mutexes [#13](https://github.com/fsnotify/fsnotify/issues/13)
|
|
||||||
* done can be an unbuffered channel
|
|
||||||
* remove calls to os.NewSyscallError
|
|
||||||
* More efficient string concatenation for Event.String() [#52](https://github.com/fsnotify/fsnotify/pull/52) (thanks @mdlayher)
|
|
||||||
* kqueue: fix regression in rework causing subdirectories to be watched [#48](https://github.com/fsnotify/fsnotify/issues/48)
|
|
||||||
* kqueue: cleanup internal watch before sending remove event [#51](https://github.com/fsnotify/fsnotify/issues/51)
|
|
||||||
|
|
||||||
## v1.0.4 / 2014-09-07
|
|
||||||
|
|
||||||
* kqueue: add dragonfly to the build tags.
|
|
||||||
* Rename source code files, rearrange code so exported APIs are at the top.
|
|
||||||
* Add done channel to example code. [#37](https://github.com/fsnotify/fsnotify/pull/37) (thanks @chenyukang)
|
|
||||||
|
|
||||||
## v1.0.3 / 2014-08-19
|
|
||||||
|
|
||||||
* [Fix] Windows MOVED_TO now translates to Create like on BSD and Linux. [#36](https://github.com/fsnotify/fsnotify/issues/36)
|
|
||||||
|
|
||||||
## v1.0.2 / 2014-08-17
|
|
||||||
|
|
||||||
* [Fix] Missing create events on macOS. [#14](https://github.com/fsnotify/fsnotify/issues/14) (thanks @zhsso)
|
|
||||||
* [Fix] Make ./path and path equivalent. (thanks @zhsso)
|
|
||||||
|
|
||||||
## v1.0.0 / 2014-08-15
|
|
||||||
|
|
||||||
* [API] Remove AddWatch on Windows, use Add.
|
|
||||||
* Improve documentation for exported identifiers. [#30](https://github.com/fsnotify/fsnotify/issues/30)
|
|
||||||
* Minor updates based on feedback from golint.
|
|
||||||
|
|
||||||
## dev / 2014-07-09
|
|
||||||
|
|
||||||
* Moved to [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify).
|
|
||||||
* Use os.NewSyscallError instead of returning errno (thanks @hariharan-uno)
|
|
||||||
|
|
||||||
## dev / 2014-07-04
|
|
||||||
|
|
||||||
* kqueue: fix incorrect mutex used in Close()
|
|
||||||
* Update example to demonstrate usage of Op.
|
|
||||||
|
|
||||||
## dev / 2014-06-28
|
|
||||||
|
|
||||||
* [API] Don't set the Write Op for attribute notifications [#4](https://github.com/fsnotify/fsnotify/issues/4)
|
|
||||||
* Fix for String() method on Event (thanks Alex Brainman)
|
|
||||||
* Don't build on Plan 9 or Solaris (thanks @4ad)
|
|
||||||
|
|
||||||
## dev / 2014-06-21
|
|
||||||
|
|
||||||
* Events channel of type Event rather than *Event.
|
|
||||||
* [internal] use syscall constants directly for inotify and kqueue.
|
|
||||||
* [internal] kqueue: rename events to kevents and fileEvent to event.
|
|
||||||
|
|
||||||
## dev / 2014-06-19
|
|
||||||
|
|
||||||
* Go 1.3+ required on Windows (uses syscall.ERROR_MORE_DATA internally).
|
|
||||||
* [internal] remove cookie from Event struct (unused).
|
|
||||||
* [internal] Event struct has the same definition across every OS.
|
|
||||||
* [internal] remove internal watch and removeWatch methods.
|
|
||||||
|
|
||||||
## dev / 2014-06-12
|
|
||||||
|
|
||||||
* [API] Renamed Watch() to Add() and RemoveWatch() to Remove().
|
|
||||||
* [API] Pluralized channel names: Events and Errors.
|
|
||||||
* [API] Renamed FileEvent struct to Event.
|
|
||||||
* [API] Op constants replace methods like IsCreate().
|
|
||||||
|
|
||||||
## dev / 2014-06-12
|
|
||||||
|
|
||||||
* Fix data race on kevent buffer (thanks @tilaks) [#98](https://github.com/howeyc/fsnotify/pull/98)
|
|
||||||
|
|
||||||
## dev / 2014-05-23
|
|
||||||
|
|
||||||
* [API] Remove current implementation of WatchFlags.
|
|
||||||
* current implementation doesn't take advantage of OS for efficiency
|
|
||||||
* provides little benefit over filtering events as they are received, but has extra bookkeeping and mutexes
|
|
||||||
* no tests for the current implementation
|
|
||||||
* not fully implemented on Windows [#93](https://github.com/howeyc/fsnotify/issues/93#issuecomment-39285195)
|
|
||||||
|
|
||||||
## v0.9.3 / 2014-12-31
|
|
||||||
|
|
||||||
* kqueue: cleanup internal watch before sending remove event [#51](https://github.com/fsnotify/fsnotify/issues/51)
|
|
||||||
|
|
||||||
## v0.9.2 / 2014-08-17
|
|
||||||
|
|
||||||
* [Backport] Fix missing create events on macOS. [#14](https://github.com/fsnotify/fsnotify/issues/14) (thanks @zhsso)
|
|
||||||
|
|
||||||
## v0.9.1 / 2014-06-12
|
|
||||||
|
|
||||||
* Fix data race on kevent buffer (thanks @tilaks) [#98](https://github.com/howeyc/fsnotify/pull/98)
|
|
||||||
|
|
||||||
## v0.9.0 / 2014-01-17
|
|
||||||
|
|
||||||
* IsAttrib() for events that only concern a file's metadata [#79][] (thanks @abustany)
|
|
||||||
* [Fix] kqueue: fix deadlock [#77][] (thanks @cespare)
|
|
||||||
* [NOTICE] Development has moved to `code.google.com/p/go.exp/fsnotify` in preparation for inclusion in the Go standard library.
|
|
||||||
|
|
||||||
## v0.8.12 / 2013-11-13
|
|
||||||
|
|
||||||
* [API] Remove FD_SET and friends from Linux adapter
|
|
||||||
|
|
||||||
## v0.8.11 / 2013-11-02
|
|
||||||
|
|
||||||
* [Doc] Add Changelog [#72][] (thanks @nathany)
|
|
||||||
* [Doc] Spotlight and double modify events on macOS [#62][] (reported by @paulhammond)
|
|
||||||
|
|
||||||
## v0.8.10 / 2013-10-19
|
|
||||||
|
|
||||||
* [Fix] kqueue: remove file watches when parent directory is removed [#71][] (reported by @mdwhatcott)
|
|
||||||
* [Fix] kqueue: race between Close and readEvents [#70][] (reported by @bernerdschaefer)
|
|
||||||
* [Doc] specify OS-specific limits in README (thanks @debrando)
|
|
||||||
|
|
||||||
## v0.8.9 / 2013-09-08
|
|
||||||
|
|
||||||
* [Doc] Contributing (thanks @nathany)
|
|
||||||
* [Doc] update package path in example code [#63][] (thanks @paulhammond)
|
|
||||||
* [Doc] GoCI badge in README (Linux only) [#60][]
|
|
||||||
* [Doc] Cross-platform testing with Vagrant [#59][] (thanks @nathany)
|
|
||||||
|
|
||||||
## v0.8.8 / 2013-06-17
|
|
||||||
|
|
||||||
* [Fix] Windows: handle `ERROR_MORE_DATA` on Windows [#49][] (thanks @jbowtie)
|
|
||||||
|
|
||||||
## v0.8.7 / 2013-06-03
|
|
||||||
|
|
||||||
* [API] Make syscall flags internal
|
|
||||||
* [Fix] inotify: ignore event changes
|
|
||||||
* [Fix] race in symlink test [#45][] (reported by @srid)
|
|
||||||
* [Fix] tests on Windows
|
|
||||||
* lower case error messages
|
|
||||||
|
|
||||||
## v0.8.6 / 2013-05-23
|
|
||||||
|
|
||||||
* kqueue: Use EVT_ONLY flag on Darwin
|
|
||||||
* [Doc] Update README with full example
|
|
||||||
|
|
||||||
## v0.8.5 / 2013-05-09
|
|
||||||
|
|
||||||
* [Fix] inotify: allow monitoring of "broken" symlinks (thanks @tsg)
|
|
||||||
|
|
||||||
## v0.8.4 / 2013-04-07
|
|
||||||
|
|
||||||
* [Fix] kqueue: watch all file events [#40][] (thanks @ChrisBuchholz)
|
|
||||||
|
|
||||||
## v0.8.3 / 2013-03-13
|
|
||||||
|
|
||||||
* [Fix] inoitfy/kqueue memory leak [#36][] (reported by @nbkolchin)
|
|
||||||
* [Fix] kqueue: use fsnFlags for watching a directory [#33][] (reported by @nbkolchin)
|
|
||||||
|
|
||||||
## v0.8.2 / 2013-02-07
|
|
||||||
|
|
||||||
* [Doc] add Authors
|
|
||||||
* [Fix] fix data races for map access [#29][] (thanks @fsouza)
|
|
||||||
|
|
||||||
## v0.8.1 / 2013-01-09
|
|
||||||
|
|
||||||
* [Fix] Windows path separators
|
|
||||||
* [Doc] BSD License
|
|
||||||
|
|
||||||
## v0.8.0 / 2012-11-09
|
|
||||||
|
|
||||||
* kqueue: directory watching improvements (thanks @vmirage)
|
|
||||||
* inotify: add `IN_MOVED_TO` [#25][] (requested by @cpisto)
|
|
||||||
* [Fix] kqueue: deleting watched directory [#24][] (reported by @jakerr)
|
|
||||||
|
|
||||||
## v0.7.4 / 2012-10-09
|
|
||||||
|
|
||||||
* [Fix] inotify: fixes from https://codereview.appspot.com/5418045/ (ugorji)
|
|
||||||
* [Fix] kqueue: preserve watch flags when watching for delete [#21][] (reported by @robfig)
|
|
||||||
* [Fix] kqueue: watch the directory even if it isn't a new watch (thanks @robfig)
|
|
||||||
* [Fix] kqueue: modify after recreation of file
|
|
||||||
|
|
||||||
## v0.7.3 / 2012-09-27
|
|
||||||
|
|
||||||
* [Fix] kqueue: watch with an existing folder inside the watched folder (thanks @vmirage)
|
|
||||||
* [Fix] kqueue: no longer get duplicate CREATE events
|
|
||||||
|
|
||||||
## v0.7.2 / 2012-09-01
|
|
||||||
|
|
||||||
* kqueue: events for created directories
|
|
||||||
|
|
||||||
## v0.7.1 / 2012-07-14
|
|
||||||
|
|
||||||
* [Fix] for renaming files
|
|
||||||
|
|
||||||
## v0.7.0 / 2012-07-02
|
|
||||||
|
|
||||||
* [Feature] FSNotify flags
|
|
||||||
* [Fix] inotify: Added file name back to event path
|
|
||||||
|
|
||||||
## v0.6.0 / 2012-06-06
|
|
||||||
|
|
||||||
* kqueue: watch files after directory created (thanks @tmc)
|
|
||||||
|
|
||||||
## v0.5.1 / 2012-05-22
|
|
||||||
|
|
||||||
* [Fix] inotify: remove all watches before Close()
|
|
||||||
|
|
||||||
## v0.5.0 / 2012-05-03
|
|
||||||
|
|
||||||
* [API] kqueue: return errors during watch instead of sending over channel
|
|
||||||
* kqueue: match symlink behavior on Linux
|
|
||||||
* inotify: add `DELETE_SELF` (requested by @taralx)
|
|
||||||
* [Fix] kqueue: handle EINTR (reported by @robfig)
|
|
||||||
* [Doc] Godoc example [#1][] (thanks @davecheney)
|
|
||||||
|
|
||||||
## v0.4.0 / 2012-03-30
|
|
||||||
|
|
||||||
* Go 1 released: build with go tool
|
|
||||||
* [Feature] Windows support using winfsnotify
|
|
||||||
* Windows does not have attribute change notifications
|
|
||||||
* Roll attribute notifications into IsModify
|
|
||||||
|
|
||||||
## v0.3.0 / 2012-02-19
|
|
||||||
|
|
||||||
* kqueue: add files when watch directory
|
|
||||||
|
|
||||||
## v0.2.0 / 2011-12-30
|
|
||||||
|
|
||||||
* update to latest Go weekly code
|
|
||||||
|
|
||||||
## v0.1.0 / 2011-10-19
|
|
||||||
|
|
||||||
* kqueue: add watch on file creation to match inotify
|
|
||||||
* kqueue: create file event
|
|
||||||
* inotify: ignore `IN_IGNORED` events
|
|
||||||
* event String()
|
|
||||||
* linux: common FileEvent functions
|
|
||||||
* initial commit
|
|
||||||
|
|
||||||
[#79]: https://github.com/howeyc/fsnotify/pull/79
|
|
||||||
[#77]: https://github.com/howeyc/fsnotify/pull/77
|
|
||||||
[#72]: https://github.com/howeyc/fsnotify/issues/72
|
|
||||||
[#71]: https://github.com/howeyc/fsnotify/issues/71
|
|
||||||
[#70]: https://github.com/howeyc/fsnotify/issues/70
|
|
||||||
[#63]: https://github.com/howeyc/fsnotify/issues/63
|
|
||||||
[#62]: https://github.com/howeyc/fsnotify/issues/62
|
|
||||||
[#60]: https://github.com/howeyc/fsnotify/issues/60
|
|
||||||
[#59]: https://github.com/howeyc/fsnotify/issues/59
|
|
||||||
[#49]: https://github.com/howeyc/fsnotify/issues/49
|
|
||||||
[#45]: https://github.com/howeyc/fsnotify/issues/45
|
|
||||||
[#40]: https://github.com/howeyc/fsnotify/issues/40
|
|
||||||
[#36]: https://github.com/howeyc/fsnotify/issues/36
|
|
||||||
[#33]: https://github.com/howeyc/fsnotify/issues/33
|
|
||||||
[#29]: https://github.com/howeyc/fsnotify/issues/29
|
|
||||||
[#25]: https://github.com/howeyc/fsnotify/issues/25
|
|
||||||
[#24]: https://github.com/howeyc/fsnotify/issues/24
|
|
||||||
[#21]: https://github.com/howeyc/fsnotify/issues/21
|
|
77
vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md
generated
vendored
77
vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md
generated
vendored
@ -1,77 +0,0 @@
|
|||||||
# Contributing
|
|
||||||
|
|
||||||
## Issues
|
|
||||||
|
|
||||||
* Request features and report bugs using the [GitHub Issue Tracker](https://github.com/fsnotify/fsnotify/issues).
|
|
||||||
* Please indicate the platform you are using fsnotify on.
|
|
||||||
* A code example to reproduce the problem is appreciated.
|
|
||||||
|
|
||||||
## Pull Requests
|
|
||||||
|
|
||||||
### Contributor License Agreement
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
Please indicate that you have signed the CLA in your pull request.
|
|
||||||
|
|
||||||
### How fsnotify is Developed
|
|
||||||
|
|
||||||
* Development is done on feature branches.
|
|
||||||
* Tests are run on BSD, Linux, macOS and Windows.
|
|
||||||
* Pull requests are reviewed and [applied to master][am] using [hub][].
|
|
||||||
* Maintainers may modify or squash commits rather than asking contributors to.
|
|
||||||
* To issue a new release, the maintainers will:
|
|
||||||
* Update the CHANGELOG
|
|
||||||
* Tag a version, which will become available through gopkg.in.
|
|
||||||
|
|
||||||
### How to Fork
|
|
||||||
|
|
||||||
For smooth sailing, always use the original import path. Installing with `go get` makes this easy.
|
|
||||||
|
|
||||||
1. Install from GitHub (`go get -u github.com/fsnotify/fsnotify`)
|
|
||||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
||||||
3. Ensure everything works and the tests pass (see below)
|
|
||||||
4. Commit your changes (`git commit -am 'Add some feature'`)
|
|
||||||
|
|
||||||
Contribute upstream:
|
|
||||||
|
|
||||||
1. Fork fsnotify on GitHub
|
|
||||||
2. Add your remote (`git remote add fork git@github.com:mycompany/repo.git`)
|
|
||||||
3. Push to the branch (`git push fork my-new-feature`)
|
|
||||||
4. Create a new Pull Request on GitHub
|
|
||||||
|
|
||||||
This workflow is [thoroughly explained by Katrina Owen](https://splice.com/blog/contributing-open-source-git-repositories-go/).
|
|
||||||
|
|
||||||
### Testing
|
|
||||||
|
|
||||||
fsnotify uses build tags to compile different code on Linux, BSD, macOS, and Windows.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
To aid in cross-platform testing there is a Vagrantfile for Linux and BSD.
|
|
||||||
|
|
||||||
* Install [Vagrant](http://www.vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/)
|
|
||||||
* Setup [Vagrant Gopher](https://github.com/nathany/vagrant-gopher) in your `src` folder.
|
|
||||||
* 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)
|
|
||||||
* 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'`.
|
|
||||||
* When you're done, you will want to halt or destroy the Vagrant boxes.
|
|
||||||
|
|
||||||
Notice: fsnotify file system events won't trigger in shared folders. The tests get around this limitation by using the /tmp directory.
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
### Maintainers
|
|
||||||
|
|
||||||
Help maintaining fsnotify is welcome. To be a maintainer:
|
|
||||||
|
|
||||||
* Submit a pull request and sign the CLA as above.
|
|
||||||
* You must be able to run the test suite on Mac, Windows, Linux and BSD.
|
|
||||||
|
|
||||||
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][].
|
|
||||||
|
|
||||||
All code changes should be internal pull requests.
|
|
||||||
|
|
||||||
Releases are tagged using [Semantic Versioning](http://semver.org/).
|
|
||||||
|
|
||||||
[hub]: https://github.com/github/hub
|
|
||||||
[am]: http://blog.spreedly.com/2014/06/24/merge-pull-request-considered-harmful/#.VGa5yZPF_Zs
|
|
28
vendor/github.com/fsnotify/fsnotify/LICENSE
generated
vendored
28
vendor/github.com/fsnotify/fsnotify/LICENSE
generated
vendored
@ -1,28 +0,0 @@
|
|||||||
Copyright (c) 2012 The Go Authors. All rights reserved.
|
|
||||||
Copyright (c) 2012 fsnotify Authors. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
79
vendor/github.com/fsnotify/fsnotify/README.md
generated
vendored
79
vendor/github.com/fsnotify/fsnotify/README.md
generated
vendored
@ -1,79 +0,0 @@
|
|||||||
# File system notifications for Go
|
|
||||||
|
|
||||||
[](https://godoc.org/github.com/fsnotify/fsnotify) [](https://goreportcard.com/report/github.com/fsnotify/fsnotify)
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
```console
|
|
||||||
go get -u golang.org/x/sys/...
|
|
||||||
```
|
|
||||||
|
|
||||||
Cross platform: Windows, Linux, BSD and macOS.
|
|
||||||
|
|
||||||
|Adapter |OS |Status |
|
|
||||||
|----------|----------|----------|
|
|
||||||
|inotify |Linux 2.6.27 or later, Android\*|Supported [](https://travis-ci.org/fsnotify/fsnotify)|
|
|
||||||
|kqueue |BSD, macOS, iOS\*|Supported [](https://travis-ci.org/fsnotify/fsnotify)|
|
|
||||||
|ReadDirectoryChangesW|Windows|Supported [](https://ci.appveyor.com/project/NathanYoungman/fsnotify/branch/master)|
|
|
||||||
|FSEvents |macOS |[Planned](https://github.com/fsnotify/fsnotify/issues/11)|
|
|
||||||
|FEN |Solaris 11 |[In Progress](https://github.com/fsnotify/fsnotify/issues/12)|
|
|
||||||
|fanotify |Linux 2.6.37+ | |
|
|
||||||
|USN Journals |Windows |[Maybe](https://github.com/fsnotify/fsnotify/issues/53)|
|
|
||||||
|Polling |*All* |[Maybe](https://github.com/fsnotify/fsnotify/issues/9)|
|
|
||||||
|
|
||||||
\* Android and iOS are untested.
|
|
||||||
|
|
||||||
Please see [the documentation](https://godoc.org/github.com/fsnotify/fsnotify) and consult the [FAQ](#faq) for usage information.
|
|
||||||
|
|
||||||
## API stability
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
Please refer to [CONTRIBUTING][] before opening an issue or pull request.
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
See [example_test.go](https://github.com/fsnotify/fsnotify/blob/master/example_test.go).
|
|
||||||
|
|
||||||
## FAQ
|
|
||||||
|
|
||||||
**When a file is moved to another directory is it still being watched?**
|
|
||||||
|
|
||||||
No (it shouldn't be, unless you are watching where it was moved to).
|
|
||||||
|
|
||||||
**When I watch a directory, are all subdirectories watched as well?**
|
|
||||||
|
|
||||||
No, you must add watches for any directory you want to watch (a recursive watcher is on the roadmap [#18][]).
|
|
||||||
|
|
||||||
**Do I have to watch the Error and Event channels in a separate goroutine?**
|
|
||||||
|
|
||||||
As of now, yes. Looking into making this single-thread friendly (see [howeyc #7][#7])
|
|
||||||
|
|
||||||
**Why am I receiving multiple events for the same file on OS X?**
|
|
||||||
|
|
||||||
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][]).
|
|
||||||
|
|
||||||
**How many files can be watched at once?**
|
|
||||||
|
|
||||||
There are OS-specific limits as to how many watches can be created:
|
|
||||||
* Linux: /proc/sys/fs/inotify/max_user_watches contains the limit, reaching this limit results in a "no space left on device" error.
|
|
||||||
* BSD / OSX: sysctl variables "kern.maxfiles" and "kern.maxfilesperproc", reaching these limits results in a "too many open files" error.
|
|
||||||
|
|
||||||
[#62]: https://github.com/howeyc/fsnotify/issues/62
|
|
||||||
[#18]: https://github.com/fsnotify/fsnotify/issues/18
|
|
||||||
[#11]: https://github.com/fsnotify/fsnotify/issues/11
|
|
||||||
[#7]: https://github.com/howeyc/fsnotify/issues/7
|
|
||||||
|
|
||||||
[contributing]: https://github.com/fsnotify/fsnotify/blob/master/CONTRIBUTING.md
|
|
||||||
|
|
||||||
## Related Projects
|
|
||||||
|
|
||||||
* [notify](https://github.com/rjeczalik/notify)
|
|
||||||
* [fsevents](https://github.com/fsnotify/fsevents)
|
|
||||||
|
|
37
vendor/github.com/fsnotify/fsnotify/fen.go
generated
vendored
37
vendor/github.com/fsnotify/fsnotify/fen.go
generated
vendored
@ -1,37 +0,0 @@
|
|||||||
// Copyright 2010 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build solaris
|
|
||||||
|
|
||||||
package fsnotify
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Watcher watches a set of files, delivering events to a channel.
|
|
||||||
type Watcher struct {
|
|
||||||
Events chan Event
|
|
||||||
Errors chan error
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
|
|
||||||
func NewWatcher() (*Watcher, error) {
|
|
||||||
return nil, errors.New("FEN based watcher not yet supported for fsnotify\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close removes all watches and closes the events channel.
|
|
||||||
func (w *Watcher) Close() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add starts watching the named file or directory (non-recursively).
|
|
||||||
func (w *Watcher) Add(name string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove stops watching the the named file or directory (non-recursively).
|
|
||||||
func (w *Watcher) Remove(name string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
66
vendor/github.com/fsnotify/fsnotify/fsnotify.go
generated
vendored
66
vendor/github.com/fsnotify/fsnotify/fsnotify.go
generated
vendored
@ -1,66 +0,0 @@
|
|||||||
// Copyright 2012 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !plan9
|
|
||||||
|
|
||||||
// Package fsnotify provides a platform-independent interface for file system notifications.
|
|
||||||
package fsnotify
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Event represents a single file system notification.
|
|
||||||
type Event struct {
|
|
||||||
Name string // Relative path to the file or directory.
|
|
||||||
Op Op // File operation that triggered the event.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Op describes a set of file operations.
|
|
||||||
type Op uint32
|
|
||||||
|
|
||||||
// These are the generalized file operations that can trigger a notification.
|
|
||||||
const (
|
|
||||||
Create Op = 1 << iota
|
|
||||||
Write
|
|
||||||
Remove
|
|
||||||
Rename
|
|
||||||
Chmod
|
|
||||||
)
|
|
||||||
|
|
||||||
func (op Op) String() string {
|
|
||||||
// Use a buffer for efficient string concatenation
|
|
||||||
var buffer bytes.Buffer
|
|
||||||
|
|
||||||
if op&Create == Create {
|
|
||||||
buffer.WriteString("|CREATE")
|
|
||||||
}
|
|
||||||
if op&Remove == Remove {
|
|
||||||
buffer.WriteString("|REMOVE")
|
|
||||||
}
|
|
||||||
if op&Write == Write {
|
|
||||||
buffer.WriteString("|WRITE")
|
|
||||||
}
|
|
||||||
if op&Rename == Rename {
|
|
||||||
buffer.WriteString("|RENAME")
|
|
||||||
}
|
|
||||||
if op&Chmod == Chmod {
|
|
||||||
buffer.WriteString("|CHMOD")
|
|
||||||
}
|
|
||||||
if buffer.Len() == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return buffer.String()[1:] // Strip leading pipe
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a string representation of the event in the form
|
|
||||||
// "file: REMOVE|WRITE|..."
|
|
||||||
func (e Event) String() string {
|
|
||||||
return fmt.Sprintf("%q: %s", e.Name, e.Op.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Common errors that can be reported by a watcher
|
|
||||||
var ErrEventOverflow = errors.New("fsnotify queue overflow")
|
|
337
vendor/github.com/fsnotify/fsnotify/inotify.go
generated
vendored
337
vendor/github.com/fsnotify/fsnotify/inotify.go
generated
vendored
@ -1,337 +0,0 @@
|
|||||||
// Copyright 2010 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package fsnotify
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Watcher watches a set of files, delivering events to a channel.
|
|
||||||
type Watcher struct {
|
|
||||||
Events chan Event
|
|
||||||
Errors chan error
|
|
||||||
mu sync.Mutex // Map access
|
|
||||||
fd int
|
|
||||||
poller *fdPoller
|
|
||||||
watches map[string]*watch // Map of inotify watches (key: path)
|
|
||||||
paths map[int]string // Map of watched paths (key: watch descriptor)
|
|
||||||
done chan struct{} // Channel for sending a "quit message" to the reader goroutine
|
|
||||||
doneResp chan struct{} // Channel to respond to Close
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
|
|
||||||
func NewWatcher() (*Watcher, error) {
|
|
||||||
// Create inotify fd
|
|
||||||
fd, errno := unix.InotifyInit1(unix.IN_CLOEXEC)
|
|
||||||
if fd == -1 {
|
|
||||||
return nil, errno
|
|
||||||
}
|
|
||||||
// Create epoll
|
|
||||||
poller, err := newFdPoller(fd)
|
|
||||||
if err != nil {
|
|
||||||
unix.Close(fd)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
w := &Watcher{
|
|
||||||
fd: fd,
|
|
||||||
poller: poller,
|
|
||||||
watches: make(map[string]*watch),
|
|
||||||
paths: make(map[int]string),
|
|
||||||
Events: make(chan Event),
|
|
||||||
Errors: make(chan error),
|
|
||||||
done: make(chan struct{}),
|
|
||||||
doneResp: make(chan struct{}),
|
|
||||||
}
|
|
||||||
|
|
||||||
go w.readEvents()
|
|
||||||
return w, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Watcher) isClosed() bool {
|
|
||||||
select {
|
|
||||||
case <-w.done:
|
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close removes all watches and closes the events channel.
|
|
||||||
func (w *Watcher) Close() error {
|
|
||||||
if w.isClosed() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send 'close' signal to goroutine, and set the Watcher to closed.
|
|
||||||
close(w.done)
|
|
||||||
|
|
||||||
// Wake up goroutine
|
|
||||||
w.poller.wake()
|
|
||||||
|
|
||||||
// Wait for goroutine to close
|
|
||||||
<-w.doneResp
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add starts watching the named file or directory (non-recursively).
|
|
||||||
func (w *Watcher) Add(name string) error {
|
|
||||||
name = filepath.Clean(name)
|
|
||||||
if w.isClosed() {
|
|
||||||
return errors.New("inotify instance already closed")
|
|
||||||
}
|
|
||||||
|
|
||||||
const agnosticEvents = unix.IN_MOVED_TO | unix.IN_MOVED_FROM |
|
|
||||||
unix.IN_CREATE | unix.IN_ATTRIB | unix.IN_MODIFY |
|
|
||||||
unix.IN_MOVE_SELF | unix.IN_DELETE | unix.IN_DELETE_SELF
|
|
||||||
|
|
||||||
var flags uint32 = agnosticEvents
|
|
||||||
|
|
||||||
w.mu.Lock()
|
|
||||||
defer w.mu.Unlock()
|
|
||||||
watchEntry := w.watches[name]
|
|
||||||
if watchEntry != nil {
|
|
||||||
flags |= watchEntry.flags | unix.IN_MASK_ADD
|
|
||||||
}
|
|
||||||
wd, errno := unix.InotifyAddWatch(w.fd, name, flags)
|
|
||||||
if wd == -1 {
|
|
||||||
return errno
|
|
||||||
}
|
|
||||||
|
|
||||||
if watchEntry == nil {
|
|
||||||
w.watches[name] = &watch{wd: uint32(wd), flags: flags}
|
|
||||||
w.paths[wd] = name
|
|
||||||
} else {
|
|
||||||
watchEntry.wd = uint32(wd)
|
|
||||||
watchEntry.flags = flags
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove stops watching the named file or directory (non-recursively).
|
|
||||||
func (w *Watcher) Remove(name string) error {
|
|
||||||
name = filepath.Clean(name)
|
|
||||||
|
|
||||||
// Fetch the watch.
|
|
||||||
w.mu.Lock()
|
|
||||||
defer w.mu.Unlock()
|
|
||||||
watch, ok := w.watches[name]
|
|
||||||
|
|
||||||
// Remove it from inotify.
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("can't remove non-existent inotify watch for: %s", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// We successfully removed the watch if InotifyRmWatch doesn't return an
|
|
||||||
// error, we need to clean up our internal state to ensure it matches
|
|
||||||
// inotify's kernel state.
|
|
||||||
delete(w.paths, int(watch.wd))
|
|
||||||
delete(w.watches, name)
|
|
||||||
|
|
||||||
// inotify_rm_watch will return EINVAL if the file has been deleted;
|
|
||||||
// the inotify will already have been removed.
|
|
||||||
// watches and pathes are deleted in ignoreLinux() implicitly and asynchronously
|
|
||||||
// by calling inotify_rm_watch() below. e.g. readEvents() goroutine receives IN_IGNORE
|
|
||||||
// so that EINVAL means that the wd is being rm_watch()ed or its file removed
|
|
||||||
// by another thread and we have not received IN_IGNORE event.
|
|
||||||
success, errno := unix.InotifyRmWatch(w.fd, watch.wd)
|
|
||||||
if success == -1 {
|
|
||||||
// TODO: Perhaps it's not helpful to return an error here in every case.
|
|
||||||
// the only two possible errors are:
|
|
||||||
// EBADF, which happens when w.fd is not a valid file descriptor of any kind.
|
|
||||||
// EINVAL, which is when fd is not an inotify descriptor or wd is not a valid watch descriptor.
|
|
||||||
// Watch descriptors are invalidated when they are removed explicitly or implicitly;
|
|
||||||
// explicitly by inotify_rm_watch, implicitly when the file they are watching is deleted.
|
|
||||||
return errno
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type watch struct {
|
|
||||||
wd uint32 // Watch descriptor (as returned by the inotify_add_watch() syscall)
|
|
||||||
flags uint32 // inotify flags of this watch (see inotify(7) for the list of valid flags)
|
|
||||||
}
|
|
||||||
|
|
||||||
// readEvents reads from the inotify file descriptor, converts the
|
|
||||||
// received events into Event objects and sends them via the Events channel
|
|
||||||
func (w *Watcher) readEvents() {
|
|
||||||
var (
|
|
||||||
buf [unix.SizeofInotifyEvent * 4096]byte // Buffer for a maximum of 4096 raw events
|
|
||||||
n int // Number of bytes read with read()
|
|
||||||
errno error // Syscall errno
|
|
||||||
ok bool // For poller.wait
|
|
||||||
)
|
|
||||||
|
|
||||||
defer close(w.doneResp)
|
|
||||||
defer close(w.Errors)
|
|
||||||
defer close(w.Events)
|
|
||||||
defer unix.Close(w.fd)
|
|
||||||
defer w.poller.close()
|
|
||||||
|
|
||||||
for {
|
|
||||||
// See if we have been closed.
|
|
||||||
if w.isClosed() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ok, errno = w.poller.wait()
|
|
||||||
if errno != nil {
|
|
||||||
select {
|
|
||||||
case w.Errors <- errno:
|
|
||||||
case <-w.done:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
n, errno = unix.Read(w.fd, buf[:])
|
|
||||||
// If a signal interrupted execution, see if we've been asked to close, and try again.
|
|
||||||
// http://man7.org/linux/man-pages/man7/signal.7.html :
|
|
||||||
// "Before Linux 3.8, reads from an inotify(7) file descriptor were not restartable"
|
|
||||||
if errno == unix.EINTR {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// unix.Read might have been woken up by Close. If so, we're done.
|
|
||||||
if w.isClosed() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if n < unix.SizeofInotifyEvent {
|
|
||||||
var err error
|
|
||||||
if n == 0 {
|
|
||||||
// If EOF is received. This should really never happen.
|
|
||||||
err = io.EOF
|
|
||||||
} else if n < 0 {
|
|
||||||
// If an error occurred while reading.
|
|
||||||
err = errno
|
|
||||||
} else {
|
|
||||||
// Read was too short.
|
|
||||||
err = errors.New("notify: short read in readEvents()")
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
case w.Errors <- err:
|
|
||||||
case <-w.done:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var offset uint32
|
|
||||||
// We don't know how many events we just read into the buffer
|
|
||||||
// While the offset points to at least one whole event...
|
|
||||||
for offset <= uint32(n-unix.SizeofInotifyEvent) {
|
|
||||||
// Point "raw" to the event in the buffer
|
|
||||||
raw := (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset]))
|
|
||||||
|
|
||||||
mask := uint32(raw.Mask)
|
|
||||||
nameLen := uint32(raw.Len)
|
|
||||||
|
|
||||||
if mask&unix.IN_Q_OVERFLOW != 0 {
|
|
||||||
select {
|
|
||||||
case w.Errors <- ErrEventOverflow:
|
|
||||||
case <-w.done:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the event happened to the watched directory or the watched file, the kernel
|
|
||||||
// doesn't append the filename to the event, but we would like to always fill the
|
|
||||||
// the "Name" field with a valid filename. We retrieve the path of the watch from
|
|
||||||
// the "paths" map.
|
|
||||||
w.mu.Lock()
|
|
||||||
name, ok := w.paths[int(raw.Wd)]
|
|
||||||
// IN_DELETE_SELF occurs when the file/directory being watched is removed.
|
|
||||||
// This is a sign to clean up the maps, otherwise we are no longer in sync
|
|
||||||
// with the inotify kernel state which has already deleted the watch
|
|
||||||
// automatically.
|
|
||||||
if ok && mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF {
|
|
||||||
delete(w.paths, int(raw.Wd))
|
|
||||||
delete(w.watches, name)
|
|
||||||
}
|
|
||||||
w.mu.Unlock()
|
|
||||||
|
|
||||||
if nameLen > 0 {
|
|
||||||
// Point "bytes" at the first byte of the filename
|
|
||||||
bytes := (*[unix.PathMax]byte)(unsafe.Pointer(&buf[offset+unix.SizeofInotifyEvent]))
|
|
||||||
// The filename is padded with NULL bytes. TrimRight() gets rid of those.
|
|
||||||
name += "/" + strings.TrimRight(string(bytes[0:nameLen]), "\000")
|
|
||||||
}
|
|
||||||
|
|
||||||
event := newEvent(name, mask)
|
|
||||||
|
|
||||||
// Send the events that are not ignored on the events channel
|
|
||||||
if !event.ignoreLinux(mask) {
|
|
||||||
select {
|
|
||||||
case w.Events <- event:
|
|
||||||
case <-w.done:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move to the next event in the buffer
|
|
||||||
offset += unix.SizeofInotifyEvent + nameLen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Certain types of events can be "ignored" and not sent over the Events
|
|
||||||
// channel. Such as events marked ignore by the kernel, or MODIFY events
|
|
||||||
// against files that do not exist.
|
|
||||||
func (e *Event) ignoreLinux(mask uint32) bool {
|
|
||||||
// Ignore anything the inotify API says to ignore
|
|
||||||
if mask&unix.IN_IGNORED == unix.IN_IGNORED {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the event is not a DELETE or RENAME, the file must exist.
|
|
||||||
// Otherwise the event is ignored.
|
|
||||||
// *Note*: this was put in place because it was seen that a MODIFY
|
|
||||||
// event was sent after the DELETE. This ignores that MODIFY and
|
|
||||||
// assumes a DELETE will come or has come if the file doesn't exist.
|
|
||||||
if !(e.Op&Remove == Remove || e.Op&Rename == Rename) {
|
|
||||||
_, statErr := os.Lstat(e.Name)
|
|
||||||
return os.IsNotExist(statErr)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// newEvent returns an platform-independent Event based on an inotify mask.
|
|
||||||
func newEvent(name string, mask uint32) Event {
|
|
||||||
e := Event{Name: name}
|
|
||||||
if mask&unix.IN_CREATE == unix.IN_CREATE || mask&unix.IN_MOVED_TO == unix.IN_MOVED_TO {
|
|
||||||
e.Op |= Create
|
|
||||||
}
|
|
||||||
if mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF || mask&unix.IN_DELETE == unix.IN_DELETE {
|
|
||||||
e.Op |= Remove
|
|
||||||
}
|
|
||||||
if mask&unix.IN_MODIFY == unix.IN_MODIFY {
|
|
||||||
e.Op |= Write
|
|
||||||
}
|
|
||||||
if mask&unix.IN_MOVE_SELF == unix.IN_MOVE_SELF || mask&unix.IN_MOVED_FROM == unix.IN_MOVED_FROM {
|
|
||||||
e.Op |= Rename
|
|
||||||
}
|
|
||||||
if mask&unix.IN_ATTRIB == unix.IN_ATTRIB {
|
|
||||||
e.Op |= Chmod
|
|
||||||
}
|
|
||||||
return e
|
|
||||||
}
|
|
187
vendor/github.com/fsnotify/fsnotify/inotify_poller.go
generated
vendored
187
vendor/github.com/fsnotify/fsnotify/inotify_poller.go
generated
vendored
@ -1,187 +0,0 @@
|
|||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package fsnotify
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
type fdPoller struct {
|
|
||||||
fd int // File descriptor (as returned by the inotify_init() syscall)
|
|
||||||
epfd int // Epoll file descriptor
|
|
||||||
pipe [2]int // Pipe for waking up
|
|
||||||
}
|
|
||||||
|
|
||||||
func emptyPoller(fd int) *fdPoller {
|
|
||||||
poller := new(fdPoller)
|
|
||||||
poller.fd = fd
|
|
||||||
poller.epfd = -1
|
|
||||||
poller.pipe[0] = -1
|
|
||||||
poller.pipe[1] = -1
|
|
||||||
return poller
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new inotify poller.
|
|
||||||
// This creates an inotify handler, and an epoll handler.
|
|
||||||
func newFdPoller(fd int) (*fdPoller, error) {
|
|
||||||
var errno error
|
|
||||||
poller := emptyPoller(fd)
|
|
||||||
defer func() {
|
|
||||||
if errno != nil {
|
|
||||||
poller.close()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
poller.fd = fd
|
|
||||||
|
|
||||||
// Create epoll fd
|
|
||||||
poller.epfd, errno = unix.EpollCreate1(0)
|
|
||||||
if poller.epfd == -1 {
|
|
||||||
return nil, errno
|
|
||||||
}
|
|
||||||
// Create pipe; pipe[0] is the read end, pipe[1] the write end.
|
|
||||||
errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK)
|
|
||||||
if errno != nil {
|
|
||||||
return nil, errno
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register inotify fd with epoll
|
|
||||||
event := unix.EpollEvent{
|
|
||||||
Fd: int32(poller.fd),
|
|
||||||
Events: unix.EPOLLIN,
|
|
||||||
}
|
|
||||||
errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.fd, &event)
|
|
||||||
if errno != nil {
|
|
||||||
return nil, errno
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register pipe fd with epoll
|
|
||||||
event = unix.EpollEvent{
|
|
||||||
Fd: int32(poller.pipe[0]),
|
|
||||||
Events: unix.EPOLLIN,
|
|
||||||
}
|
|
||||||
errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.pipe[0], &event)
|
|
||||||
if errno != nil {
|
|
||||||
return nil, errno
|
|
||||||
}
|
|
||||||
|
|
||||||
return poller, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait using epoll.
|
|
||||||
// Returns true if something is ready to be read,
|
|
||||||
// false if there is not.
|
|
||||||
func (poller *fdPoller) wait() (bool, error) {
|
|
||||||
// 3 possible events per fd, and 2 fds, makes a maximum of 6 events.
|
|
||||||
// I don't know whether epoll_wait returns the number of events returned,
|
|
||||||
// or the total number of events ready.
|
|
||||||
// I decided to catch both by making the buffer one larger than the maximum.
|
|
||||||
events := make([]unix.EpollEvent, 7)
|
|
||||||
for {
|
|
||||||
n, errno := unix.EpollWait(poller.epfd, events, -1)
|
|
||||||
if n == -1 {
|
|
||||||
if errno == unix.EINTR {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return false, errno
|
|
||||||
}
|
|
||||||
if n == 0 {
|
|
||||||
// If there are no events, try again.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if n > 6 {
|
|
||||||
// This should never happen. More events were returned than should be possible.
|
|
||||||
return false, errors.New("epoll_wait returned more events than I know what to do with")
|
|
||||||
}
|
|
||||||
ready := events[:n]
|
|
||||||
epollhup := false
|
|
||||||
epollerr := false
|
|
||||||
epollin := false
|
|
||||||
for _, event := range ready {
|
|
||||||
if event.Fd == int32(poller.fd) {
|
|
||||||
if event.Events&unix.EPOLLHUP != 0 {
|
|
||||||
// This should not happen, but if it does, treat it as a wakeup.
|
|
||||||
epollhup = true
|
|
||||||
}
|
|
||||||
if event.Events&unix.EPOLLERR != 0 {
|
|
||||||
// If an error is waiting on the file descriptor, we should pretend
|
|
||||||
// something is ready to read, and let unix.Read pick up the error.
|
|
||||||
epollerr = true
|
|
||||||
}
|
|
||||||
if event.Events&unix.EPOLLIN != 0 {
|
|
||||||
// There is data to read.
|
|
||||||
epollin = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if event.Fd == int32(poller.pipe[0]) {
|
|
||||||
if event.Events&unix.EPOLLHUP != 0 {
|
|
||||||
// Write pipe descriptor was closed, by us. This means we're closing down the
|
|
||||||
// watcher, and we should wake up.
|
|
||||||
}
|
|
||||||
if event.Events&unix.EPOLLERR != 0 {
|
|
||||||
// If an error is waiting on the pipe file descriptor.
|
|
||||||
// This is an absolute mystery, and should never ever happen.
|
|
||||||
return false, errors.New("Error on the pipe descriptor.")
|
|
||||||
}
|
|
||||||
if event.Events&unix.EPOLLIN != 0 {
|
|
||||||
// This is a regular wakeup, so we have to clear the buffer.
|
|
||||||
err := poller.clearWake()
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if epollhup || epollerr || epollin {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the write end of the poller.
|
|
||||||
func (poller *fdPoller) wake() error {
|
|
||||||
buf := make([]byte, 1)
|
|
||||||
n, errno := unix.Write(poller.pipe[1], buf)
|
|
||||||
if n == -1 {
|
|
||||||
if errno == unix.EAGAIN {
|
|
||||||
// Buffer is full, poller will wake.
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return errno
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (poller *fdPoller) clearWake() error {
|
|
||||||
// You have to be woken up a LOT in order to get to 100!
|
|
||||||
buf := make([]byte, 100)
|
|
||||||
n, errno := unix.Read(poller.pipe[0], buf)
|
|
||||||
if n == -1 {
|
|
||||||
if errno == unix.EAGAIN {
|
|
||||||
// Buffer is empty, someone else cleared our wake.
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return errno
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close all poller file descriptors, but not the one passed to it.
|
|
||||||
func (poller *fdPoller) close() {
|
|
||||||
if poller.pipe[1] != -1 {
|
|
||||||
unix.Close(poller.pipe[1])
|
|
||||||
}
|
|
||||||
if poller.pipe[0] != -1 {
|
|
||||||
unix.Close(poller.pipe[0])
|
|
||||||
}
|
|
||||||
if poller.epfd != -1 {
|
|
||||||
unix.Close(poller.epfd)
|
|
||||||
}
|
|
||||||
}
|
|
503
vendor/github.com/fsnotify/fsnotify/kqueue.go
generated
vendored
503
vendor/github.com/fsnotify/fsnotify/kqueue.go
generated
vendored
@ -1,503 +0,0 @@
|
|||||||
// Copyright 2010 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build freebsd openbsd netbsd dragonfly darwin
|
|
||||||
|
|
||||||
package fsnotify
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Watcher watches a set of files, delivering events to a channel.
|
|
||||||
type Watcher struct {
|
|
||||||
Events chan Event
|
|
||||||
Errors chan error
|
|
||||||
done chan bool // Channel for sending a "quit message" to the reader goroutine
|
|
||||||
|
|
||||||
kq int // File descriptor (as returned by the kqueue() syscall).
|
|
||||||
|
|
||||||
mu sync.Mutex // Protects access to watcher data
|
|
||||||
watches map[string]int // Map of watched file descriptors (key: path).
|
|
||||||
externalWatches map[string]bool // Map of watches added by user of the library.
|
|
||||||
dirFlags map[string]uint32 // Map of watched directories to fflags used in kqueue.
|
|
||||||
paths map[int]pathInfo // Map file descriptors to path names for processing kqueue events.
|
|
||||||
fileExists map[string]bool // Keep track of if we know this file exists (to stop duplicate create events).
|
|
||||||
isClosed bool // Set to true when Close() is first called
|
|
||||||
}
|
|
||||||
|
|
||||||
type pathInfo struct {
|
|
||||||
name string
|
|
||||||
isDir bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
|
|
||||||
func NewWatcher() (*Watcher, error) {
|
|
||||||
kq, err := kqueue()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
w := &Watcher{
|
|
||||||
kq: kq,
|
|
||||||
watches: make(map[string]int),
|
|
||||||
dirFlags: make(map[string]uint32),
|
|
||||||
paths: make(map[int]pathInfo),
|
|
||||||
fileExists: make(map[string]bool),
|
|
||||||
externalWatches: make(map[string]bool),
|
|
||||||
Events: make(chan Event),
|
|
||||||
Errors: make(chan error),
|
|
||||||
done: make(chan bool),
|
|
||||||
}
|
|
||||||
|
|
||||||
go w.readEvents()
|
|
||||||
return w, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close removes all watches and closes the events channel.
|
|
||||||
func (w *Watcher) Close() error {
|
|
||||||
w.mu.Lock()
|
|
||||||
if w.isClosed {
|
|
||||||
w.mu.Unlock()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
w.isClosed = true
|
|
||||||
w.mu.Unlock()
|
|
||||||
|
|
||||||
// copy paths to remove while locked
|
|
||||||
w.mu.Lock()
|
|
||||||
var pathsToRemove = make([]string, 0, len(w.watches))
|
|
||||||
for name := range w.watches {
|
|
||||||
pathsToRemove = append(pathsToRemove, name)
|
|
||||||
}
|
|
||||||
w.mu.Unlock()
|
|
||||||
// unlock before calling Remove, which also locks
|
|
||||||
|
|
||||||
var err error
|
|
||||||
for _, name := range pathsToRemove {
|
|
||||||
if e := w.Remove(name); e != nil && err == nil {
|
|
||||||
err = e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send "quit" message to the reader goroutine:
|
|
||||||
w.done <- true
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add starts watching the named file or directory (non-recursively).
|
|
||||||
func (w *Watcher) Add(name string) error {
|
|
||||||
w.mu.Lock()
|
|
||||||
w.externalWatches[name] = true
|
|
||||||
w.mu.Unlock()
|
|
||||||
_, err := w.addWatch(name, noteAllEvents)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove stops watching the the named file or directory (non-recursively).
|
|
||||||
func (w *Watcher) Remove(name string) error {
|
|
||||||
name = filepath.Clean(name)
|
|
||||||
w.mu.Lock()
|
|
||||||
watchfd, ok := w.watches[name]
|
|
||||||
w.mu.Unlock()
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("can't remove non-existent kevent watch for: %s", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
const registerRemove = unix.EV_DELETE
|
|
||||||
if err := register(w.kq, []int{watchfd}, registerRemove, 0); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
unix.Close(watchfd)
|
|
||||||
|
|
||||||
w.mu.Lock()
|
|
||||||
isDir := w.paths[watchfd].isDir
|
|
||||||
delete(w.watches, name)
|
|
||||||
delete(w.paths, watchfd)
|
|
||||||
delete(w.dirFlags, name)
|
|
||||||
w.mu.Unlock()
|
|
||||||
|
|
||||||
// Find all watched paths that are in this directory that are not external.
|
|
||||||
if isDir {
|
|
||||||
var pathsToRemove []string
|
|
||||||
w.mu.Lock()
|
|
||||||
for _, path := range w.paths {
|
|
||||||
wdir, _ := filepath.Split(path.name)
|
|
||||||
if filepath.Clean(wdir) == name {
|
|
||||||
if !w.externalWatches[path.name] {
|
|
||||||
pathsToRemove = append(pathsToRemove, path.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
w.mu.Unlock()
|
|
||||||
for _, name := range pathsToRemove {
|
|
||||||
// Since these are internal, not much sense in propagating error
|
|
||||||
// to the user, as that will just confuse them with an error about
|
|
||||||
// a path they did not explicitly watch themselves.
|
|
||||||
w.Remove(name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch all events (except NOTE_EXTEND, NOTE_LINK, NOTE_REVOKE)
|
|
||||||
const noteAllEvents = unix.NOTE_DELETE | unix.NOTE_WRITE | unix.NOTE_ATTRIB | unix.NOTE_RENAME
|
|
||||||
|
|
||||||
// keventWaitTime to block on each read from kevent
|
|
||||||
var keventWaitTime = durationToTimespec(100 * time.Millisecond)
|
|
||||||
|
|
||||||
// addWatch adds name to the watched file set.
|
|
||||||
// The flags are interpreted as described in kevent(2).
|
|
||||||
// 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.
|
|
||||||
func (w *Watcher) addWatch(name string, flags uint32) (string, error) {
|
|
||||||
var isDir bool
|
|
||||||
// Make ./name and name equivalent
|
|
||||||
name = filepath.Clean(name)
|
|
||||||
|
|
||||||
w.mu.Lock()
|
|
||||||
if w.isClosed {
|
|
||||||
w.mu.Unlock()
|
|
||||||
return "", errors.New("kevent instance already closed")
|
|
||||||
}
|
|
||||||
watchfd, alreadyWatching := w.watches[name]
|
|
||||||
// We already have a watch, but we can still override flags.
|
|
||||||
if alreadyWatching {
|
|
||||||
isDir = w.paths[watchfd].isDir
|
|
||||||
}
|
|
||||||
w.mu.Unlock()
|
|
||||||
|
|
||||||
if !alreadyWatching {
|
|
||||||
fi, err := os.Lstat(name)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't watch sockets.
|
|
||||||
if fi.Mode()&os.ModeSocket == os.ModeSocket {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't watch named pipes.
|
|
||||||
if fi.Mode()&os.ModeNamedPipe == os.ModeNamedPipe {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Follow Symlinks
|
|
||||||
// Unfortunately, Linux can add bogus symlinks to watch list without
|
|
||||||
// issue, and Windows can't do symlinks period (AFAIK). To maintain
|
|
||||||
// consistency, we will act like everything is fine. There will simply
|
|
||||||
// be no file events for broken symlinks.
|
|
||||||
// Hence the returns of nil on errors.
|
|
||||||
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
|
|
||||||
name, err = filepath.EvalSymlinks(name)
|
|
||||||
if err != nil {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
w.mu.Lock()
|
|
||||||
_, alreadyWatching = w.watches[name]
|
|
||||||
w.mu.Unlock()
|
|
||||||
|
|
||||||
if alreadyWatching {
|
|
||||||
return name, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
fi, err = os.Lstat(name)
|
|
||||||
if err != nil {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watchfd, err = unix.Open(name, openMode, 0700)
|
|
||||||
if watchfd == -1 {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
isDir = fi.IsDir()
|
|
||||||
}
|
|
||||||
|
|
||||||
const registerAdd = unix.EV_ADD | unix.EV_CLEAR | unix.EV_ENABLE
|
|
||||||
if err := register(w.kq, []int{watchfd}, registerAdd, flags); err != nil {
|
|
||||||
unix.Close(watchfd)
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !alreadyWatching {
|
|
||||||
w.mu.Lock()
|
|
||||||
w.watches[name] = watchfd
|
|
||||||
w.paths[watchfd] = pathInfo{name: name, isDir: isDir}
|
|
||||||
w.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
if isDir {
|
|
||||||
// Watch the directory if it has not been watched before,
|
|
||||||
// or if it was watched before, but perhaps only a NOTE_DELETE (watchDirectoryFiles)
|
|
||||||
w.mu.Lock()
|
|
||||||
|
|
||||||
watchDir := (flags&unix.NOTE_WRITE) == unix.NOTE_WRITE &&
|
|
||||||
(!alreadyWatching || (w.dirFlags[name]&unix.NOTE_WRITE) != unix.NOTE_WRITE)
|
|
||||||
// Store flags so this watch can be updated later
|
|
||||||
w.dirFlags[name] = flags
|
|
||||||
w.mu.Unlock()
|
|
||||||
|
|
||||||
if watchDir {
|
|
||||||
if err := w.watchDirectoryFiles(name); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return name, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// readEvents reads from kqueue and converts the received kevents into
|
|
||||||
// Event values that it sends down the Events channel.
|
|
||||||
func (w *Watcher) readEvents() {
|
|
||||||
eventBuffer := make([]unix.Kevent_t, 10)
|
|
||||||
|
|
||||||
for {
|
|
||||||
// See if there is a message on the "done" channel
|
|
||||||
select {
|
|
||||||
case <-w.done:
|
|
||||||
err := unix.Close(w.kq)
|
|
||||||
if err != nil {
|
|
||||||
w.Errors <- err
|
|
||||||
}
|
|
||||||
close(w.Events)
|
|
||||||
close(w.Errors)
|
|
||||||
return
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get new events
|
|
||||||
kevents, err := read(w.kq, eventBuffer, &keventWaitTime)
|
|
||||||
// EINTR is okay, the syscall was interrupted before timeout expired.
|
|
||||||
if err != nil && err != unix.EINTR {
|
|
||||||
w.Errors <- err
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flush the events we received to the Events channel
|
|
||||||
for len(kevents) > 0 {
|
|
||||||
kevent := &kevents[0]
|
|
||||||
watchfd := int(kevent.Ident)
|
|
||||||
mask := uint32(kevent.Fflags)
|
|
||||||
w.mu.Lock()
|
|
||||||
path := w.paths[watchfd]
|
|
||||||
w.mu.Unlock()
|
|
||||||
event := newEvent(path.name, mask)
|
|
||||||
|
|
||||||
if path.isDir && !(event.Op&Remove == Remove) {
|
|
||||||
// Double check to make sure the directory exists. This can happen when
|
|
||||||
// we do a rm -fr on a recursively watched folders and we receive a
|
|
||||||
// modification event first but the folder has been deleted and later
|
|
||||||
// receive the delete event
|
|
||||||
if _, err := os.Lstat(event.Name); os.IsNotExist(err) {
|
|
||||||
// mark is as delete event
|
|
||||||
event.Op |= Remove
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if event.Op&Rename == Rename || event.Op&Remove == Remove {
|
|
||||||
w.Remove(event.Name)
|
|
||||||
w.mu.Lock()
|
|
||||||
delete(w.fileExists, event.Name)
|
|
||||||
w.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
if path.isDir && event.Op&Write == Write && !(event.Op&Remove == Remove) {
|
|
||||||
w.sendDirectoryChangeEvents(event.Name)
|
|
||||||
} else {
|
|
||||||
// Send the event on the Events channel
|
|
||||||
w.Events <- event
|
|
||||||
}
|
|
||||||
|
|
||||||
if event.Op&Remove == Remove {
|
|
||||||
// Look for a file that may have overwritten this.
|
|
||||||
// For example, mv f1 f2 will delete f2, then create f2.
|
|
||||||
if path.isDir {
|
|
||||||
fileDir := filepath.Clean(event.Name)
|
|
||||||
w.mu.Lock()
|
|
||||||
_, found := w.watches[fileDir]
|
|
||||||
w.mu.Unlock()
|
|
||||||
if found {
|
|
||||||
// make sure the directory exists before we watch for changes. When we
|
|
||||||
// do a recursive watch and perform rm -fr, the parent directory might
|
|
||||||
// have gone missing, ignore the missing directory and let the
|
|
||||||
// upcoming delete event remove the watch from the parent directory.
|
|
||||||
if _, err := os.Lstat(fileDir); err == nil {
|
|
||||||
w.sendDirectoryChangeEvents(fileDir)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
filePath := filepath.Clean(event.Name)
|
|
||||||
if fileInfo, err := os.Lstat(filePath); err == nil {
|
|
||||||
w.sendFileCreatedEventIfNew(filePath, fileInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move to next event
|
|
||||||
kevents = kevents[1:]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// newEvent returns an platform-independent Event based on kqueue Fflags.
|
|
||||||
func newEvent(name string, mask uint32) Event {
|
|
||||||
e := Event{Name: name}
|
|
||||||
if mask&unix.NOTE_DELETE == unix.NOTE_DELETE {
|
|
||||||
e.Op |= Remove
|
|
||||||
}
|
|
||||||
if mask&unix.NOTE_WRITE == unix.NOTE_WRITE {
|
|
||||||
e.Op |= Write
|
|
||||||
}
|
|
||||||
if mask&unix.NOTE_RENAME == unix.NOTE_RENAME {
|
|
||||||
e.Op |= Rename
|
|
||||||
}
|
|
||||||
if mask&unix.NOTE_ATTRIB == unix.NOTE_ATTRIB {
|
|
||||||
e.Op |= Chmod
|
|
||||||
}
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
|
|
||||||
func newCreateEvent(name string) Event {
|
|
||||||
return Event{Name: name, Op: Create}
|
|
||||||
}
|
|
||||||
|
|
||||||
// watchDirectoryFiles to mimic inotify when adding a watch on a directory
|
|
||||||
func (w *Watcher) watchDirectoryFiles(dirPath string) error {
|
|
||||||
// Get all files
|
|
||||||
files, err := ioutil.ReadDir(dirPath)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, fileInfo := range files {
|
|
||||||
filePath := filepath.Join(dirPath, fileInfo.Name())
|
|
||||||
filePath, err = w.internalWatch(filePath, fileInfo)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
w.mu.Lock()
|
|
||||||
w.fileExists[filePath] = true
|
|
||||||
w.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// sendDirectoryEvents searches the directory for newly created files
|
|
||||||
// and sends them over the event channel. This functionality is to have
|
|
||||||
// the BSD version of fsnotify match Linux inotify which provides a
|
|
||||||
// create event for files created in a watched directory.
|
|
||||||
func (w *Watcher) sendDirectoryChangeEvents(dirPath string) {
|
|
||||||
// Get all files
|
|
||||||
files, err := ioutil.ReadDir(dirPath)
|
|
||||||
if err != nil {
|
|
||||||
w.Errors <- err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for new files
|
|
||||||
for _, fileInfo := range files {
|
|
||||||
filePath := filepath.Join(dirPath, fileInfo.Name())
|
|
||||||
err := w.sendFileCreatedEventIfNew(filePath, fileInfo)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sendFileCreatedEvent sends a create event if the file isn't already being tracked.
|
|
||||||
func (w *Watcher) sendFileCreatedEventIfNew(filePath string, fileInfo os.FileInfo) (err error) {
|
|
||||||
w.mu.Lock()
|
|
||||||
_, doesExist := w.fileExists[filePath]
|
|
||||||
w.mu.Unlock()
|
|
||||||
if !doesExist {
|
|
||||||
// Send create event
|
|
||||||
w.Events <- newCreateEvent(filePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// like watchDirectoryFiles (but without doing another ReadDir)
|
|
||||||
filePath, err = w.internalWatch(filePath, fileInfo)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
w.mu.Lock()
|
|
||||||
w.fileExists[filePath] = true
|
|
||||||
w.mu.Unlock()
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Watcher) internalWatch(name string, fileInfo os.FileInfo) (string, error) {
|
|
||||||
if fileInfo.IsDir() {
|
|
||||||
// mimic Linux providing delete events for subdirectories
|
|
||||||
// but preserve the flags used if currently watching subdirectory
|
|
||||||
w.mu.Lock()
|
|
||||||
flags := w.dirFlags[name]
|
|
||||||
w.mu.Unlock()
|
|
||||||
|
|
||||||
flags |= unix.NOTE_DELETE | unix.NOTE_RENAME
|
|
||||||
return w.addWatch(name, flags)
|
|
||||||
}
|
|
||||||
|
|
||||||
// watch file to mimic Linux inotify
|
|
||||||
return w.addWatch(name, noteAllEvents)
|
|
||||||
}
|
|
||||||
|
|
||||||
// kqueue creates a new kernel event queue and returns a descriptor.
|
|
||||||
func kqueue() (kq int, err error) {
|
|
||||||
kq, err = unix.Kqueue()
|
|
||||||
if kq == -1 {
|
|
||||||
return kq, err
|
|
||||||
}
|
|
||||||
return kq, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// register events with the queue
|
|
||||||
func register(kq int, fds []int, flags int, fflags uint32) error {
|
|
||||||
changes := make([]unix.Kevent_t, len(fds))
|
|
||||||
|
|
||||||
for i, fd := range fds {
|
|
||||||
// SetKevent converts int to the platform-specific types:
|
|
||||||
unix.SetKevent(&changes[i], fd, unix.EVFILT_VNODE, flags)
|
|
||||||
changes[i].Fflags = fflags
|
|
||||||
}
|
|
||||||
|
|
||||||
// register the events
|
|
||||||
success, err := unix.Kevent(kq, changes, nil, nil)
|
|
||||||
if success == -1 {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// read retrieves pending events, or waits until an event occurs.
|
|
||||||
// A timeout of nil blocks indefinitely, while 0 polls the queue.
|
|
||||||
func read(kq int, events []unix.Kevent_t, timeout *unix.Timespec) ([]unix.Kevent_t, error) {
|
|
||||||
n, err := unix.Kevent(kq, nil, events, timeout)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return events[0:n], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// durationToTimespec prepares a timeout value
|
|
||||||
func durationToTimespec(d time.Duration) unix.Timespec {
|
|
||||||
return unix.NsecToTimespec(d.Nanoseconds())
|
|
||||||
}
|
|
11
vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go
generated
vendored
11
vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go
generated
vendored
@ -1,11 +0,0 @@
|
|||||||
// Copyright 2013 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build freebsd openbsd netbsd dragonfly
|
|
||||||
|
|
||||||
package fsnotify
|
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
|
||||||
|
|
||||||
const openMode = unix.O_NONBLOCK | unix.O_RDONLY
|
|
12
vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go
generated
vendored
12
vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go
generated
vendored
@ -1,12 +0,0 @@
|
|||||||
// Copyright 2013 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package fsnotify
|
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
|
||||||
|
|
||||||
// note: this constant is not defined on BSD
|
|
||||||
const openMode = unix.O_EVTONLY
|
|
561
vendor/github.com/fsnotify/fsnotify/windows.go
generated
vendored
561
vendor/github.com/fsnotify/fsnotify/windows.go
generated
vendored
@ -1,561 +0,0 @@
|
|||||||
// Copyright 2011 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package fsnotify
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
"sync"
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Watcher watches a set of files, delivering events to a channel.
|
|
||||||
type Watcher struct {
|
|
||||||
Events chan Event
|
|
||||||
Errors chan error
|
|
||||||
isClosed bool // Set to true when Close() is first called
|
|
||||||
mu sync.Mutex // Map access
|
|
||||||
port syscall.Handle // Handle to completion port
|
|
||||||
watches watchMap // Map of watches (key: i-number)
|
|
||||||
input chan *input // Inputs to the reader are sent on this channel
|
|
||||||
quit chan chan<- error
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
|
|
||||||
func NewWatcher() (*Watcher, error) {
|
|
||||||
port, e := syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 0)
|
|
||||||
if e != nil {
|
|
||||||
return nil, os.NewSyscallError("CreateIoCompletionPort", e)
|
|
||||||
}
|
|
||||||
w := &Watcher{
|
|
||||||
port: port,
|
|
||||||
watches: make(watchMap),
|
|
||||||
input: make(chan *input, 1),
|
|
||||||
Events: make(chan Event, 50),
|
|
||||||
Errors: make(chan error),
|
|
||||||
quit: make(chan chan<- error, 1),
|
|
||||||
}
|
|
||||||
go w.readEvents()
|
|
||||||
return w, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close removes all watches and closes the events channel.
|
|
||||||
func (w *Watcher) Close() error {
|
|
||||||
if w.isClosed {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
w.isClosed = true
|
|
||||||
|
|
||||||
// Send "quit" message to the reader goroutine
|
|
||||||
ch := make(chan error)
|
|
||||||
w.quit <- ch
|
|
||||||
if err := w.wakeupReader(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return <-ch
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add starts watching the named file or directory (non-recursively).
|
|
||||||
func (w *Watcher) Add(name string) error {
|
|
||||||
if w.isClosed {
|
|
||||||
return errors.New("watcher already closed")
|
|
||||||
}
|
|
||||||
in := &input{
|
|
||||||
op: opAddWatch,
|
|
||||||
path: filepath.Clean(name),
|
|
||||||
flags: sysFSALLEVENTS,
|
|
||||||
reply: make(chan error),
|
|
||||||
}
|
|
||||||
w.input <- in
|
|
||||||
if err := w.wakeupReader(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return <-in.reply
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove stops watching the the named file or directory (non-recursively).
|
|
||||||
func (w *Watcher) Remove(name string) error {
|
|
||||||
in := &input{
|
|
||||||
op: opRemoveWatch,
|
|
||||||
path: filepath.Clean(name),
|
|
||||||
reply: make(chan error),
|
|
||||||
}
|
|
||||||
w.input <- in
|
|
||||||
if err := w.wakeupReader(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return <-in.reply
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Options for AddWatch
|
|
||||||
sysFSONESHOT = 0x80000000
|
|
||||||
sysFSONLYDIR = 0x1000000
|
|
||||||
|
|
||||||
// Events
|
|
||||||
sysFSACCESS = 0x1
|
|
||||||
sysFSALLEVENTS = 0xfff
|
|
||||||
sysFSATTRIB = 0x4
|
|
||||||
sysFSCLOSE = 0x18
|
|
||||||
sysFSCREATE = 0x100
|
|
||||||
sysFSDELETE = 0x200
|
|
||||||
sysFSDELETESELF = 0x400
|
|
||||||
sysFSMODIFY = 0x2
|
|
||||||
sysFSMOVE = 0xc0
|
|
||||||
sysFSMOVEDFROM = 0x40
|
|
||||||
sysFSMOVEDTO = 0x80
|
|
||||||
sysFSMOVESELF = 0x800
|
|
||||||
|
|
||||||
// Special events
|
|
||||||
sysFSIGNORED = 0x8000
|
|
||||||
sysFSQOVERFLOW = 0x4000
|
|
||||||
)
|
|
||||||
|
|
||||||
func newEvent(name string, mask uint32) Event {
|
|
||||||
e := Event{Name: name}
|
|
||||||
if mask&sysFSCREATE == sysFSCREATE || mask&sysFSMOVEDTO == sysFSMOVEDTO {
|
|
||||||
e.Op |= Create
|
|
||||||
}
|
|
||||||
if mask&sysFSDELETE == sysFSDELETE || mask&sysFSDELETESELF == sysFSDELETESELF {
|
|
||||||
e.Op |= Remove
|
|
||||||
}
|
|
||||||
if mask&sysFSMODIFY == sysFSMODIFY {
|
|
||||||
e.Op |= Write
|
|
||||||
}
|
|
||||||
if mask&sysFSMOVE == sysFSMOVE || mask&sysFSMOVESELF == sysFSMOVESELF || mask&sysFSMOVEDFROM == sysFSMOVEDFROM {
|
|
||||||
e.Op |= Rename
|
|
||||||
}
|
|
||||||
if mask&sysFSATTRIB == sysFSATTRIB {
|
|
||||||
e.Op |= Chmod
|
|
||||||
}
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
opAddWatch = iota
|
|
||||||
opRemoveWatch
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
provisional uint64 = 1 << (32 + iota)
|
|
||||||
)
|
|
||||||
|
|
||||||
type input struct {
|
|
||||||
op int
|
|
||||||
path string
|
|
||||||
flags uint32
|
|
||||||
reply chan error
|
|
||||||
}
|
|
||||||
|
|
||||||
type inode struct {
|
|
||||||
handle syscall.Handle
|
|
||||||
volume uint32
|
|
||||||
index uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
type watch struct {
|
|
||||||
ov syscall.Overlapped
|
|
||||||
ino *inode // i-number
|
|
||||||
path string // Directory path
|
|
||||||
mask uint64 // Directory itself is being watched with these notify flags
|
|
||||||
names map[string]uint64 // Map of names being watched and their notify flags
|
|
||||||
rename string // Remembers the old name while renaming a file
|
|
||||||
buf [4096]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type indexMap map[uint64]*watch
|
|
||||||
type watchMap map[uint32]indexMap
|
|
||||||
|
|
||||||
func (w *Watcher) wakeupReader() error {
|
|
||||||
e := syscall.PostQueuedCompletionStatus(w.port, 0, 0, nil)
|
|
||||||
if e != nil {
|
|
||||||
return os.NewSyscallError("PostQueuedCompletionStatus", e)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getDir(pathname string) (dir string, err error) {
|
|
||||||
attr, e := syscall.GetFileAttributes(syscall.StringToUTF16Ptr(pathname))
|
|
||||||
if e != nil {
|
|
||||||
return "", os.NewSyscallError("GetFileAttributes", e)
|
|
||||||
}
|
|
||||||
if attr&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 {
|
|
||||||
dir = pathname
|
|
||||||
} else {
|
|
||||||
dir, _ = filepath.Split(pathname)
|
|
||||||
dir = filepath.Clean(dir)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func getIno(path string) (ino *inode, err error) {
|
|
||||||
h, e := syscall.CreateFile(syscall.StringToUTF16Ptr(path),
|
|
||||||
syscall.FILE_LIST_DIRECTORY,
|
|
||||||
syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
|
|
||||||
nil, syscall.OPEN_EXISTING,
|
|
||||||
syscall.FILE_FLAG_BACKUP_SEMANTICS|syscall.FILE_FLAG_OVERLAPPED, 0)
|
|
||||||
if e != nil {
|
|
||||||
return nil, os.NewSyscallError("CreateFile", e)
|
|
||||||
}
|
|
||||||
var fi syscall.ByHandleFileInformation
|
|
||||||
if e = syscall.GetFileInformationByHandle(h, &fi); e != nil {
|
|
||||||
syscall.CloseHandle(h)
|
|
||||||
return nil, os.NewSyscallError("GetFileInformationByHandle", e)
|
|
||||||
}
|
|
||||||
ino = &inode{
|
|
||||||
handle: h,
|
|
||||||
volume: fi.VolumeSerialNumber,
|
|
||||||
index: uint64(fi.FileIndexHigh)<<32 | uint64(fi.FileIndexLow),
|
|
||||||
}
|
|
||||||
return ino, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must run within the I/O thread.
|
|
||||||
func (m watchMap) get(ino *inode) *watch {
|
|
||||||
if i := m[ino.volume]; i != nil {
|
|
||||||
return i[ino.index]
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must run within the I/O thread.
|
|
||||||
func (m watchMap) set(ino *inode, watch *watch) {
|
|
||||||
i := m[ino.volume]
|
|
||||||
if i == nil {
|
|
||||||
i = make(indexMap)
|
|
||||||
m[ino.volume] = i
|
|
||||||
}
|
|
||||||
i[ino.index] = watch
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must run within the I/O thread.
|
|
||||||
func (w *Watcher) addWatch(pathname string, flags uint64) error {
|
|
||||||
dir, err := getDir(pathname)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if flags&sysFSONLYDIR != 0 && pathname != dir {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
ino, err := getIno(dir)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.mu.Lock()
|
|
||||||
watchEntry := w.watches.get(ino)
|
|
||||||
w.mu.Unlock()
|
|
||||||
if watchEntry == nil {
|
|
||||||
if _, e := syscall.CreateIoCompletionPort(ino.handle, w.port, 0, 0); e != nil {
|
|
||||||
syscall.CloseHandle(ino.handle)
|
|
||||||
return os.NewSyscallError("CreateIoCompletionPort", e)
|
|
||||||
}
|
|
||||||
watchEntry = &watch{
|
|
||||||
ino: ino,
|
|
||||||
path: dir,
|
|
||||||
names: make(map[string]uint64),
|
|
||||||
}
|
|
||||||
w.mu.Lock()
|
|
||||||
w.watches.set(ino, watchEntry)
|
|
||||||
w.mu.Unlock()
|
|
||||||
flags |= provisional
|
|
||||||
} else {
|
|
||||||
syscall.CloseHandle(ino.handle)
|
|
||||||
}
|
|
||||||
if pathname == dir {
|
|
||||||
watchEntry.mask |= flags
|
|
||||||
} else {
|
|
||||||
watchEntry.names[filepath.Base(pathname)] |= flags
|
|
||||||
}
|
|
||||||
if err = w.startRead(watchEntry); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if pathname == dir {
|
|
||||||
watchEntry.mask &= ^provisional
|
|
||||||
} else {
|
|
||||||
watchEntry.names[filepath.Base(pathname)] &= ^provisional
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must run within the I/O thread.
|
|
||||||
func (w *Watcher) remWatch(pathname string) error {
|
|
||||||
dir, err := getDir(pathname)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
ino, err := getIno(dir)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.mu.Lock()
|
|
||||||
watch := w.watches.get(ino)
|
|
||||||
w.mu.Unlock()
|
|
||||||
if watch == nil {
|
|
||||||
return fmt.Errorf("can't remove non-existent watch for: %s", pathname)
|
|
||||||
}
|
|
||||||
if pathname == dir {
|
|
||||||
w.sendEvent(watch.path, watch.mask&sysFSIGNORED)
|
|
||||||
watch.mask = 0
|
|
||||||
} else {
|
|
||||||
name := filepath.Base(pathname)
|
|
||||||
w.sendEvent(filepath.Join(watch.path, name), watch.names[name]&sysFSIGNORED)
|
|
||||||
delete(watch.names, name)
|
|
||||||
}
|
|
||||||
return w.startRead(watch)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must run within the I/O thread.
|
|
||||||
func (w *Watcher) deleteWatch(watch *watch) {
|
|
||||||
for name, mask := range watch.names {
|
|
||||||
if mask&provisional == 0 {
|
|
||||||
w.sendEvent(filepath.Join(watch.path, name), mask&sysFSIGNORED)
|
|
||||||
}
|
|
||||||
delete(watch.names, name)
|
|
||||||
}
|
|
||||||
if watch.mask != 0 {
|
|
||||||
if watch.mask&provisional == 0 {
|
|
||||||
w.sendEvent(watch.path, watch.mask&sysFSIGNORED)
|
|
||||||
}
|
|
||||||
watch.mask = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must run within the I/O thread.
|
|
||||||
func (w *Watcher) startRead(watch *watch) error {
|
|
||||||
if e := syscall.CancelIo(watch.ino.handle); e != nil {
|
|
||||||
w.Errors <- os.NewSyscallError("CancelIo", e)
|
|
||||||
w.deleteWatch(watch)
|
|
||||||
}
|
|
||||||
mask := toWindowsFlags(watch.mask)
|
|
||||||
for _, m := range watch.names {
|
|
||||||
mask |= toWindowsFlags(m)
|
|
||||||
}
|
|
||||||
if mask == 0 {
|
|
||||||
if e := syscall.CloseHandle(watch.ino.handle); e != nil {
|
|
||||||
w.Errors <- os.NewSyscallError("CloseHandle", e)
|
|
||||||
}
|
|
||||||
w.mu.Lock()
|
|
||||||
delete(w.watches[watch.ino.volume], watch.ino.index)
|
|
||||||
w.mu.Unlock()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
e := syscall.ReadDirectoryChanges(watch.ino.handle, &watch.buf[0],
|
|
||||||
uint32(unsafe.Sizeof(watch.buf)), false, mask, nil, &watch.ov, 0)
|
|
||||||
if e != nil {
|
|
||||||
err := os.NewSyscallError("ReadDirectoryChanges", e)
|
|
||||||
if e == syscall.ERROR_ACCESS_DENIED && watch.mask&provisional == 0 {
|
|
||||||
// Watched directory was probably removed
|
|
||||||
if w.sendEvent(watch.path, watch.mask&sysFSDELETESELF) {
|
|
||||||
if watch.mask&sysFSONESHOT != 0 {
|
|
||||||
watch.mask = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
w.deleteWatch(watch)
|
|
||||||
w.startRead(watch)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// readEvents reads from the I/O completion port, converts the
|
|
||||||
// received events into Event objects and sends them via the Events channel.
|
|
||||||
// Entry point to the I/O thread.
|
|
||||||
func (w *Watcher) readEvents() {
|
|
||||||
var (
|
|
||||||
n, key uint32
|
|
||||||
ov *syscall.Overlapped
|
|
||||||
)
|
|
||||||
runtime.LockOSThread()
|
|
||||||
|
|
||||||
for {
|
|
||||||
e := syscall.GetQueuedCompletionStatus(w.port, &n, &key, &ov, syscall.INFINITE)
|
|
||||||
watch := (*watch)(unsafe.Pointer(ov))
|
|
||||||
|
|
||||||
if watch == nil {
|
|
||||||
select {
|
|
||||||
case ch := <-w.quit:
|
|
||||||
w.mu.Lock()
|
|
||||||
var indexes []indexMap
|
|
||||||
for _, index := range w.watches {
|
|
||||||
indexes = append(indexes, index)
|
|
||||||
}
|
|
||||||
w.mu.Unlock()
|
|
||||||
for _, index := range indexes {
|
|
||||||
for _, watch := range index {
|
|
||||||
w.deleteWatch(watch)
|
|
||||||
w.startRead(watch)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var err error
|
|
||||||
if e := syscall.CloseHandle(w.port); e != nil {
|
|
||||||
err = os.NewSyscallError("CloseHandle", e)
|
|
||||||
}
|
|
||||||
close(w.Events)
|
|
||||||
close(w.Errors)
|
|
||||||
ch <- err
|
|
||||||
return
|
|
||||||
case in := <-w.input:
|
|
||||||
switch in.op {
|
|
||||||
case opAddWatch:
|
|
||||||
in.reply <- w.addWatch(in.path, uint64(in.flags))
|
|
||||||
case opRemoveWatch:
|
|
||||||
in.reply <- w.remWatch(in.path)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
switch e {
|
|
||||||
case syscall.ERROR_MORE_DATA:
|
|
||||||
if watch == nil {
|
|
||||||
w.Errors <- errors.New("ERROR_MORE_DATA has unexpectedly null lpOverlapped buffer")
|
|
||||||
} else {
|
|
||||||
// The i/o succeeded but the buffer is full.
|
|
||||||
// In theory we should be building up a full packet.
|
|
||||||
// In practice we can get away with just carrying on.
|
|
||||||
n = uint32(unsafe.Sizeof(watch.buf))
|
|
||||||
}
|
|
||||||
case syscall.ERROR_ACCESS_DENIED:
|
|
||||||
// Watched directory was probably removed
|
|
||||||
w.sendEvent(watch.path, watch.mask&sysFSDELETESELF)
|
|
||||||
w.deleteWatch(watch)
|
|
||||||
w.startRead(watch)
|
|
||||||
continue
|
|
||||||
case syscall.ERROR_OPERATION_ABORTED:
|
|
||||||
// CancelIo was called on this handle
|
|
||||||
continue
|
|
||||||
default:
|
|
||||||
w.Errors <- os.NewSyscallError("GetQueuedCompletionPort", e)
|
|
||||||
continue
|
|
||||||
case nil:
|
|
||||||
}
|
|
||||||
|
|
||||||
var offset uint32
|
|
||||||
for {
|
|
||||||
if n == 0 {
|
|
||||||
w.Events <- newEvent("", sysFSQOVERFLOW)
|
|
||||||
w.Errors <- errors.New("short read in readEvents()")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// Point "raw" to the event in the buffer
|
|
||||||
raw := (*syscall.FileNotifyInformation)(unsafe.Pointer(&watch.buf[offset]))
|
|
||||||
buf := (*[syscall.MAX_PATH]uint16)(unsafe.Pointer(&raw.FileName))
|
|
||||||
name := syscall.UTF16ToString(buf[:raw.FileNameLength/2])
|
|
||||||
fullname := filepath.Join(watch.path, name)
|
|
||||||
|
|
||||||
var mask uint64
|
|
||||||
switch raw.Action {
|
|
||||||
case syscall.FILE_ACTION_REMOVED:
|
|
||||||
mask = sysFSDELETESELF
|
|
||||||
case syscall.FILE_ACTION_MODIFIED:
|
|
||||||
mask = sysFSMODIFY
|
|
||||||
case syscall.FILE_ACTION_RENAMED_OLD_NAME:
|
|
||||||
watch.rename = name
|
|
||||||
case syscall.FILE_ACTION_RENAMED_NEW_NAME:
|
|
||||||
if watch.names[watch.rename] != 0 {
|
|
||||||
watch.names[name] |= watch.names[watch.rename]
|
|
||||||
delete(watch.names, watch.rename)
|
|
||||||
mask = sysFSMOVESELF
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendNameEvent := func() {
|
|
||||||
if w.sendEvent(fullname, watch.names[name]&mask) {
|
|
||||||
if watch.names[name]&sysFSONESHOT != 0 {
|
|
||||||
delete(watch.names, name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if raw.Action != syscall.FILE_ACTION_RENAMED_NEW_NAME {
|
|
||||||
sendNameEvent()
|
|
||||||
}
|
|
||||||
if raw.Action == syscall.FILE_ACTION_REMOVED {
|
|
||||||
w.sendEvent(fullname, watch.names[name]&sysFSIGNORED)
|
|
||||||
delete(watch.names, name)
|
|
||||||
}
|
|
||||||
if w.sendEvent(fullname, watch.mask&toFSnotifyFlags(raw.Action)) {
|
|
||||||
if watch.mask&sysFSONESHOT != 0 {
|
|
||||||
watch.mask = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if raw.Action == syscall.FILE_ACTION_RENAMED_NEW_NAME {
|
|
||||||
fullname = filepath.Join(watch.path, watch.rename)
|
|
||||||
sendNameEvent()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move to the next event in the buffer
|
|
||||||
if raw.NextEntryOffset == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
offset += raw.NextEntryOffset
|
|
||||||
|
|
||||||
// Error!
|
|
||||||
if offset >= n {
|
|
||||||
w.Errors <- errors.New("Windows system assumed buffer larger than it is, events have likely been missed.")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := w.startRead(watch); err != nil {
|
|
||||||
w.Errors <- err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Watcher) sendEvent(name string, mask uint64) bool {
|
|
||||||
if mask == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
event := newEvent(name, uint32(mask))
|
|
||||||
select {
|
|
||||||
case ch := <-w.quit:
|
|
||||||
w.quit <- ch
|
|
||||||
case w.Events <- event:
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func toWindowsFlags(mask uint64) uint32 {
|
|
||||||
var m uint32
|
|
||||||
if mask&sysFSACCESS != 0 {
|
|
||||||
m |= syscall.FILE_NOTIFY_CHANGE_LAST_ACCESS
|
|
||||||
}
|
|
||||||
if mask&sysFSMODIFY != 0 {
|
|
||||||
m |= syscall.FILE_NOTIFY_CHANGE_LAST_WRITE
|
|
||||||
}
|
|
||||||
if mask&sysFSATTRIB != 0 {
|
|
||||||
m |= syscall.FILE_NOTIFY_CHANGE_ATTRIBUTES
|
|
||||||
}
|
|
||||||
if mask&(sysFSMOVE|sysFSCREATE|sysFSDELETE) != 0 {
|
|
||||||
m |= syscall.FILE_NOTIFY_CHANGE_FILE_NAME | syscall.FILE_NOTIFY_CHANGE_DIR_NAME
|
|
||||||
}
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
func toFSnotifyFlags(action uint32) uint64 {
|
|
||||||
switch action {
|
|
||||||
case syscall.FILE_ACTION_ADDED:
|
|
||||||
return sysFSCREATE
|
|
||||||
case syscall.FILE_ACTION_REMOVED:
|
|
||||||
return sysFSDELETE
|
|
||||||
case syscall.FILE_ACTION_MODIFIED:
|
|
||||||
return sysFSMODIFY
|
|
||||||
case syscall.FILE_ACTION_RENAMED_OLD_NAME:
|
|
||||||
return sysFSMOVEDFROM
|
|
||||||
case syscall.FILE_ACTION_RENAMED_NEW_NAME:
|
|
||||||
return sysFSMOVEDTO
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
8
vendor/github.com/mvdan/sh/interp/builtin.go
generated
vendored
8
vendor/github.com/mvdan/sh/interp/builtin.go
generated
vendored
@ -206,8 +206,8 @@ func (r *Runner) builtinCode(pos syntax.Pos, name string, args []string) int {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
r2 := *r
|
r2 := *r
|
||||||
r2.Node = file
|
r2.Reset()
|
||||||
r2.Run()
|
r2.Run(file)
|
||||||
return r2.exit
|
return r2.exit
|
||||||
case "source", ".":
|
case "source", ".":
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
@ -227,8 +227,8 @@ func (r *Runner) builtinCode(pos syntax.Pos, name string, args []string) int {
|
|||||||
}
|
}
|
||||||
r2 := *r
|
r2 := *r
|
||||||
r2.Params = args[1:]
|
r2.Params = args[1:]
|
||||||
r2.Node = file
|
r2.Reset()
|
||||||
r2.Run()
|
r2.Run(file)
|
||||||
return r2.exit
|
return r2.exit
|
||||||
case "[":
|
case "[":
|
||||||
if len(args) == 0 || args[len(args)-1] != "]" {
|
if len(args) == 0 || args[len(args)-1] != "]" {
|
||||||
|
50
vendor/github.com/mvdan/sh/interp/interp.go
generated
vendored
50
vendor/github.com/mvdan/sh/interp/interp.go
generated
vendored
@ -29,8 +29,6 @@ import (
|
|||||||
// concurrent use, consider a workaround like hiding writes behind a
|
// concurrent use, consider a workaround like hiding writes behind a
|
||||||
// mutex.
|
// mutex.
|
||||||
type Runner struct {
|
type Runner struct {
|
||||||
Node syntax.Node
|
|
||||||
|
|
||||||
// Env specifies the environment of the interpreter.
|
// Env specifies the environment of the interpreter.
|
||||||
// If Env is nil, Run uses the current process's environment.
|
// If Env is nil, Run uses the current process's environment.
|
||||||
Env []string
|
Env []string
|
||||||
@ -48,6 +46,8 @@ type Runner struct {
|
|||||||
// of vars.
|
// of vars.
|
||||||
Params []string
|
Params []string
|
||||||
|
|
||||||
|
filename string // only if Node was a File
|
||||||
|
|
||||||
// Separate maps, note that bash allows a name to be both a var
|
// Separate maps, note that bash allows a name to be both a var
|
||||||
// and a func simultaneously
|
// and a func simultaneously
|
||||||
vars map[string]varValue
|
vars map[string]varValue
|
||||||
@ -137,8 +137,9 @@ func (e RunError) Error() string {
|
|||||||
func (r *Runner) runErr(pos syntax.Pos, format string, a ...interface{}) {
|
func (r *Runner) runErr(pos syntax.Pos, format string, a ...interface{}) {
|
||||||
if r.err == nil {
|
if r.err == nil {
|
||||||
r.err = RunError{
|
r.err = RunError{
|
||||||
Pos: pos,
|
Filename: r.filename,
|
||||||
Text: fmt.Sprintf(format, a...),
|
Pos: pos,
|
||||||
|
Text: fmt.Sprintf(format, a...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,8 +219,17 @@ opts:
|
|||||||
return args, nil
|
return args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run starts the interpreter and returns any error.
|
func (r *Runner) Reset() error {
|
||||||
func (r *Runner) Run() error {
|
// reset the internal state
|
||||||
|
*r = Runner{
|
||||||
|
Env: r.Env,
|
||||||
|
Dir: r.Dir,
|
||||||
|
Params: r.Params,
|
||||||
|
Context: r.Context,
|
||||||
|
Stdin: r.Stdin,
|
||||||
|
Stdout: r.Stdout,
|
||||||
|
Stderr: r.Stderr,
|
||||||
|
}
|
||||||
if r.Context == nil {
|
if r.Context == nil {
|
||||||
r.Context = context.Background()
|
r.Context = context.Background()
|
||||||
}
|
}
|
||||||
@ -242,8 +252,15 @@ func (r *Runner) Run() error {
|
|||||||
}
|
}
|
||||||
r.Dir = dir
|
r.Dir = dir
|
||||||
}
|
}
|
||||||
switch x := r.Node.(type) {
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run starts the interpreter and returns any error.
|
||||||
|
func (r *Runner) Run(node syntax.Node) error {
|
||||||
|
r.filename = ""
|
||||||
|
switch x := node.(type) {
|
||||||
case *syntax.File:
|
case *syntax.File:
|
||||||
|
r.filename = x.Name
|
||||||
r.stmts(x.StmtList)
|
r.stmts(x.StmtList)
|
||||||
case *syntax.Stmt:
|
case *syntax.Stmt:
|
||||||
r.stmt(x)
|
r.stmt(x)
|
||||||
@ -291,16 +308,29 @@ func (r *Runner) expand(format string, onlyChars bool, args ...string) string {
|
|||||||
if fmt {
|
if fmt {
|
||||||
fmt = false
|
fmt = false
|
||||||
arg := ""
|
arg := ""
|
||||||
|
n := 0
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
arg, args = args[0], args[1:]
|
arg, args = args[0], args[1:]
|
||||||
|
i, _ := strconv.ParseInt(arg, 0, 0)
|
||||||
|
n = int(i)
|
||||||
}
|
}
|
||||||
switch c {
|
switch c {
|
||||||
case 's':
|
case 's':
|
||||||
buf.WriteString(arg)
|
buf.WriteString(arg)
|
||||||
case 'd':
|
case 'c':
|
||||||
// round-trip to convert invalid to 0
|
var b byte
|
||||||
n, _ := strconv.Atoi(arg)
|
if len(arg) > 0 {
|
||||||
|
b = arg[0]
|
||||||
|
}
|
||||||
|
buf.WriteByte(b)
|
||||||
|
case 'd', 'i':
|
||||||
buf.WriteString(strconv.Itoa(n))
|
buf.WriteString(strconv.Itoa(n))
|
||||||
|
case 'u':
|
||||||
|
buf.WriteString(strconv.FormatUint(uint64(n), 10))
|
||||||
|
case 'o':
|
||||||
|
buf.WriteString(strconv.FormatUint(uint64(n), 8))
|
||||||
|
case 'x':
|
||||||
|
buf.WriteString(strconv.FormatUint(uint64(n), 16))
|
||||||
default:
|
default:
|
||||||
r.runErr(syntax.Pos{}, "unhandled format char: %c", c)
|
r.runErr(syntax.Pos{}, "unhandled format char: %c", c)
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/mvdan/sh/interp/param.go
generated
vendored
2
vendor/github.com/mvdan/sh/interp/param.go
generated
vendored
@ -62,7 +62,7 @@ func (r *Runner) paramExp(pe *syntax.ParamExp) string {
|
|||||||
switch {
|
switch {
|
||||||
case pe.Length:
|
case pe.Length:
|
||||||
str = strconv.Itoa(utf8.RuneCountInString(str))
|
str = strconv.Itoa(utf8.RuneCountInString(str))
|
||||||
case pe.Indirect:
|
case pe.Excl:
|
||||||
val, set = r.lookupVar(str)
|
val, set = r.lookupVar(str)
|
||||||
str = varStr(val)
|
str = varStr(val)
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/mvdan/sh/syntax/nodes.go
generated
vendored
2
vendor/github.com/mvdan/sh/syntax/nodes.go
generated
vendored
@ -465,7 +465,7 @@ func (c *CmdSubst) End() Pos { return posAddCol(c.Right, 1) }
|
|||||||
type ParamExp struct {
|
type ParamExp struct {
|
||||||
Dollar, Rbrace Pos
|
Dollar, Rbrace Pos
|
||||||
Short bool // $a instead of ${a}
|
Short bool // $a instead of ${a}
|
||||||
Indirect bool // ${!a}
|
Excl bool // ${!a}
|
||||||
Length bool // ${#a}
|
Length bool // ${#a}
|
||||||
Width bool // ${%a}
|
Width bool // ${%a}
|
||||||
Param *Lit
|
Param *Lit
|
||||||
|
41
vendor/github.com/mvdan/sh/syntax/parser.go
generated
vendored
41
vendor/github.com/mvdan/sh/syntax/parser.go
generated
vendored
@ -795,14 +795,14 @@ func arithmOpLevel(op BinAritOperator) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Parser) followArithm(ftok token, fpos Pos) ArithmExpr {
|
func (p *Parser) followArithm(ftok token, fpos Pos) ArithmExpr {
|
||||||
x := p.arithmExpr(ftok, fpos, 0, false, false)
|
x := p.arithmExpr(0, false, false)
|
||||||
if x == nil {
|
if x == nil {
|
||||||
p.followErrExp(fpos, ftok.String())
|
p.followErrExp(fpos, ftok.String())
|
||||||
}
|
}
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Parser) arithmExpr(ftok token, fpos Pos, level int, compact, tern bool) ArithmExpr {
|
func (p *Parser) arithmExpr(level int, compact, tern bool) ArithmExpr {
|
||||||
if p.tok == _EOF || p.peekArithmEnd() {
|
if p.tok == _EOF || p.peekArithmEnd() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -810,7 +810,7 @@ func (p *Parser) arithmExpr(ftok token, fpos Pos, level int, compact, tern bool)
|
|||||||
if level > 11 {
|
if level > 11 {
|
||||||
left = p.arithmExprBase(compact)
|
left = p.arithmExprBase(compact)
|
||||||
} else {
|
} else {
|
||||||
left = p.arithmExpr(ftok, fpos, level+1, compact, false)
|
left = p.arithmExpr(level+1, compact, false)
|
||||||
}
|
}
|
||||||
if compact && p.spaced {
|
if compact && p.spaced {
|
||||||
return left
|
return left
|
||||||
@ -861,7 +861,7 @@ func (p *Parser) arithmExpr(ftok token, fpos Pos, level int, compact, tern bool)
|
|||||||
if p.next(); compact && p.spaced {
|
if p.next(); compact && p.spaced {
|
||||||
p.followErrExp(b.OpPos, b.Op.String())
|
p.followErrExp(b.OpPos, b.Op.String())
|
||||||
}
|
}
|
||||||
b.Y = p.arithmExpr(token(b.Op), b.OpPos, newLevel, compact, b.Op == Quest)
|
b.Y = p.arithmExpr(newLevel, compact, b.Op == Quest)
|
||||||
if b.Y == nil {
|
if b.Y == nil {
|
||||||
p.followErrExp(b.OpPos, b.Op.String())
|
p.followErrExp(b.OpPos, b.Op.String())
|
||||||
}
|
}
|
||||||
@ -1017,7 +1017,7 @@ func (p *Parser) paramExp() *ParamExp {
|
|||||||
}
|
}
|
||||||
case exclMark:
|
case exclMark:
|
||||||
if paramNameOp(p.r) {
|
if paramNameOp(p.r) {
|
||||||
pe.Indirect = true
|
pe.Excl = true
|
||||||
p.next()
|
p.next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1385,6 +1385,8 @@ func (p *Parser) getStmt(readEnd, binCmd bool) (s *Stmt, gotEnd bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Parser) gotStmtPipe(s *Stmt) *Stmt {
|
func (p *Parser) gotStmtPipe(s *Stmt) *Stmt {
|
||||||
|
s.Comments = append(s.Comments, p.accComs...)
|
||||||
|
p.accComs = nil
|
||||||
switch p.tok {
|
switch p.tok {
|
||||||
case _LitWord:
|
case _LitWord:
|
||||||
switch p.val {
|
switch p.val {
|
||||||
@ -1412,6 +1414,11 @@ func (p *Parser) gotStmtPipe(s *Stmt) *Stmt {
|
|||||||
p.curErr(`%q can only be used to end a loop`, p.val)
|
p.curErr(`%q can only be used to end a loop`, p.val)
|
||||||
case "esac":
|
case "esac":
|
||||||
p.curErr(`%q can only be used to end a case`, p.val)
|
p.curErr(`%q can only be used to end a case`, p.val)
|
||||||
|
case "!":
|
||||||
|
if !s.Negated {
|
||||||
|
p.curErr(`"!" can only be used in full statements`)
|
||||||
|
break
|
||||||
|
}
|
||||||
case "[[":
|
case "[[":
|
||||||
if p.lang != LangPOSIX {
|
if p.lang != LangPOSIX {
|
||||||
s.Cmd = p.testClause()
|
s.Cmd = p.testClause()
|
||||||
@ -1477,7 +1484,7 @@ func (p *Parser) gotStmtPipe(s *Stmt) *Stmt {
|
|||||||
s.Cmd = p.callExpr(s, nil, false)
|
s.Cmd = p.callExpr(s, nil, false)
|
||||||
case bckQuote:
|
case bckQuote:
|
||||||
if p.quote == subCmdBckquo {
|
if p.quote == subCmdBckquo {
|
||||||
return s
|
return nil
|
||||||
}
|
}
|
||||||
fallthrough
|
fallthrough
|
||||||
case _Lit, dollBrace, dollDblParen, dollParen, dollar, cmdIn, cmdOut,
|
case _Lit, dollBrace, dollDblParen, dollParen, dollar, cmdIn, cmdOut,
|
||||||
@ -1520,18 +1527,6 @@ func (p *Parser) gotStmtPipe(s *Stmt) *Stmt {
|
|||||||
s = p.stmt(s.Position)
|
s = p.stmt(s.Position)
|
||||||
s.Cmd = b
|
s.Cmd = b
|
||||||
s.Comments, b.X.Comments = b.X.Comments, nil
|
s.Comments, b.X.Comments = b.X.Comments, nil
|
||||||
move := 0
|
|
||||||
for _, c := range p.accComs {
|
|
||||||
// inline comment belongs in the parent
|
|
||||||
if c.Hash.Line() >= b.Y.End().Line() {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
move++
|
|
||||||
}
|
|
||||||
if move > 0 {
|
|
||||||
b.Y.Comments = p.accComs[:move]
|
|
||||||
p.accComs = p.accComs[move:]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@ -1637,15 +1632,13 @@ func (p *Parser) loop(fpos Pos) Loop {
|
|||||||
cl := &CStyleLoop{Lparen: p.pos}
|
cl := &CStyleLoop{Lparen: p.pos}
|
||||||
old := p.preNested(arithmExprCmd)
|
old := p.preNested(arithmExprCmd)
|
||||||
p.next()
|
p.next()
|
||||||
cl.Init = p.arithmExpr(dblLeftParen, cl.Lparen, 0, false, false)
|
cl.Init = p.arithmExpr(0, false, false)
|
||||||
scPos := p.pos
|
|
||||||
if !p.got(dblSemicolon) {
|
if !p.got(dblSemicolon) {
|
||||||
p.follow(p.pos, "expr", semicolon)
|
p.follow(p.pos, "expr", semicolon)
|
||||||
cl.Cond = p.arithmExpr(semicolon, scPos, 0, false, false)
|
cl.Cond = p.arithmExpr(0, false, false)
|
||||||
scPos = p.pos
|
|
||||||
p.follow(p.pos, "expr", semicolon)
|
p.follow(p.pos, "expr", semicolon)
|
||||||
}
|
}
|
||||||
cl.Post = p.arithmExpr(semicolon, scPos, 0, false, false)
|
cl.Post = p.arithmExpr(0, false, false)
|
||||||
cl.Rparen = p.arithmEnd(dblLeftParen, cl.Lparen, old)
|
cl.Rparen = p.arithmEnd(dblLeftParen, cl.Lparen, old)
|
||||||
p.gotSameLine(semicolon)
|
p.gotSameLine(semicolon)
|
||||||
return cl
|
return cl
|
||||||
@ -1959,7 +1952,7 @@ func (p *Parser) letClause() *LetClause {
|
|||||||
old := p.preNested(arithmExprLet)
|
old := p.preNested(arithmExprLet)
|
||||||
p.next()
|
p.next()
|
||||||
for !p.newLine && !stopToken(p.tok) && !p.peekRedir() {
|
for !p.newLine && !stopToken(p.tok) && !p.peekRedir() {
|
||||||
x := p.arithmExpr(illegalTok, lc.Let, 0, true, false)
|
x := p.arithmExpr(0, true, false)
|
||||||
if x == nil {
|
if x == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
12
vendor/github.com/mvdan/sh/syntax/printer.go
generated
vendored
12
vendor/github.com/mvdan/sh/syntax/printer.go
generated
vendored
@ -196,11 +196,11 @@ func (p *Printer) newlines(pos Pos) {
|
|||||||
p.indent()
|
p.indent()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) sepTok(s string, pos Pos) {
|
func (p *Printer) rightParen(pos Pos) {
|
||||||
if p.wantNewline || pos.Line() > p.line {
|
if p.wantNewline || pos.Line() > p.line {
|
||||||
p.newlines(pos)
|
p.newlines(pos)
|
||||||
}
|
}
|
||||||
p.WriteString(s)
|
p.WriteByte(')')
|
||||||
p.wantSpace = true
|
p.wantSpace = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ func (p *Printer) wordPart(wp WordPart) {
|
|||||||
p.WriteString("$(")
|
p.WriteString("$(")
|
||||||
p.wantSpace = len(x.Stmts) > 0 && startsWithLparen(x.Stmts[0])
|
p.wantSpace = len(x.Stmts) > 0 && startsWithLparen(x.Stmts[0])
|
||||||
p.nestedStmts(x.StmtList, x.Right)
|
p.nestedStmts(x.StmtList, x.Right)
|
||||||
p.sepTok(")", x.Right)
|
p.rightParen(x.Right)
|
||||||
}
|
}
|
||||||
case *ParamExp:
|
case *ParamExp:
|
||||||
p.paramExp(x)
|
p.paramExp(x)
|
||||||
@ -339,7 +339,7 @@ func (p *Printer) paramExp(pe *ParamExp) {
|
|||||||
p.WriteByte('#')
|
p.WriteByte('#')
|
||||||
case pe.Width:
|
case pe.Width:
|
||||||
p.WriteByte('%')
|
p.WriteByte('%')
|
||||||
case pe.Indirect:
|
case pe.Excl:
|
||||||
p.WriteByte('!')
|
p.WriteByte('!')
|
||||||
}
|
}
|
||||||
p.WriteString(pe.Param.Value)
|
p.WriteString(pe.Param.Value)
|
||||||
@ -615,7 +615,7 @@ func (p *Printer) command(cmd Command, redirs []*Redirect) (startRedirs int) {
|
|||||||
p.WriteByte('(')
|
p.WriteByte('(')
|
||||||
p.wantSpace = len(x.Stmts) > 0 && startsWithLparen(x.Stmts[0])
|
p.wantSpace = len(x.Stmts) > 0 && startsWithLparen(x.Stmts[0])
|
||||||
p.nestedStmts(x.StmtList, x.Rparen)
|
p.nestedStmts(x.StmtList, x.Rparen)
|
||||||
p.sepTok(")", x.Rparen)
|
p.rightParen(x.Rparen)
|
||||||
case *WhileClause:
|
case *WhileClause:
|
||||||
if x.Until {
|
if x.Until {
|
||||||
p.spacedString("until")
|
p.spacedString("until")
|
||||||
@ -968,7 +968,7 @@ func (p *Printer) assigns(assigns []*Assign, alwaysEqual bool) {
|
|||||||
p.wantSpace = false
|
p.wantSpace = false
|
||||||
p.WriteByte('(')
|
p.WriteByte('(')
|
||||||
p.elemJoin(a.Array.Elems, a.Array.Last)
|
p.elemJoin(a.Array.Elems, a.Array.Last)
|
||||||
p.sepTok(")", a.Array.Rparen)
|
p.rightParen(a.Array.Rparen)
|
||||||
}
|
}
|
||||||
p.wantSpace = true
|
p.wantSpace = true
|
||||||
}
|
}
|
||||||
|
6
vendor/github.com/mvdan/sh/syntax/simplify.go
generated
vendored
6
vendor/github.com/mvdan/sh/syntax/simplify.go
generated
vendored
@ -10,9 +10,9 @@ import "bytes"
|
|||||||
//
|
//
|
||||||
// This function is EXPERIMENTAL; it may change or disappear at any
|
// This function is EXPERIMENTAL; it may change or disappear at any
|
||||||
// point until this notice is removed.
|
// point until this notice is removed.
|
||||||
func Simplify(f *File) bool {
|
func Simplify(n Node) bool {
|
||||||
s := simplifier{}
|
s := simplifier{}
|
||||||
Walk(f, s.visit)
|
Walk(n, s.visit)
|
||||||
return s.modified
|
return s.modified
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ func (s *simplifier) inlineSimpleParams(x ArithmExpr) ArithmExpr {
|
|||||||
if pe == nil || !ValidName(pe.Param.Value) {
|
if pe == nil || !ValidName(pe.Param.Value) {
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
if pe.Indirect || pe.Length || pe.Width || pe.Slice != nil ||
|
if pe.Excl || pe.Length || pe.Width || pe.Slice != nil ||
|
||||||
pe.Repl != nil || pe.Exp != nil {
|
pe.Repl != nil || pe.Exp != nil {
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
4
vendor/github.com/radovskyb/watcher/.travis.yml
generated
vendored
Normal file
4
vendor/github.com/radovskyb/watcher/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
language: go
|
||||||
|
go:
|
||||||
|
- 1.7
|
||||||
|
- tip
|
27
vendor/github.com/radovskyb/watcher/LICENSE
generated
vendored
Normal file
27
vendor/github.com/radovskyb/watcher/LICENSE
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Copyright (c) 2016, Benjamin Radovsky.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of watcher nor the names of its contributors may be used to
|
||||||
|
endorse or promote products derived from this software without specific prior
|
||||||
|
written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
165
vendor/github.com/radovskyb/watcher/README.md
generated
vendored
Normal file
165
vendor/github.com/radovskyb/watcher/README.md
generated
vendored
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
# watcher
|
||||||
|
|
||||||
|
[](https://travis-ci.org/radovskyb/watcher)
|
||||||
|
|
||||||
|
`watcher` is a Go package for watching for files or directory changes (recursively or non recursively) without using filesystem events, which allows it to work cross platform consistently.
|
||||||
|
|
||||||
|
`watcher` watches for changes and notifies over channels either anytime an event or an error has occurred.
|
||||||
|
|
||||||
|
Events contain the `os.FileInfo` of the file or directory that the event is based on and the type of event and file or directory path.
|
||||||
|
|
||||||
|
# Update
|
||||||
|
Event.Path for Rename and Move events is now returned in the format of `fromPath -> toPath`
|
||||||
|
|
||||||
|
|
||||||
|
#### Chmod event is not supported under windows.
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
```shell
|
||||||
|
go get -u github.com/radovskyb/watcher/...
|
||||||
|
```
|
||||||
|
|
||||||
|
# Features
|
||||||
|
|
||||||
|
- Customizable polling interval.
|
||||||
|
- Filter Events.
|
||||||
|
- Watch folders recursively or non-recursively.
|
||||||
|
- Choose to ignore hidden files.
|
||||||
|
- Choose to ignore specified files and folders.
|
||||||
|
- Notifies the `os.FileInfo` of the file that the event is based on. e.g `Name`, `ModTime`, `IsDir`, etc.
|
||||||
|
- Notifies the full path of the file that the event is based on or the old and new paths if the event was a `Rename` or `Move` event.
|
||||||
|
- Limit amount of events that can be received per watching cycle.
|
||||||
|
- List the files being watched.
|
||||||
|
- Trigger custom events.
|
||||||
|
|
||||||
|
# Todo
|
||||||
|
|
||||||
|
- Write more tests.
|
||||||
|
- Write benchmarks.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/radovskyb/watcher"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
w := watcher.New()
|
||||||
|
|
||||||
|
// SetMaxEvents to 1 to allow at most 1 event's to be received
|
||||||
|
// on the Event channel per watching cycle.
|
||||||
|
//
|
||||||
|
// If SetMaxEvents is not set, the default is to send all events.
|
||||||
|
w.SetMaxEvents(1)
|
||||||
|
|
||||||
|
// Only notify rename and move events.
|
||||||
|
w.FilterOps(watcher.Rename, watcher.Move)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case event := <-w.Event:
|
||||||
|
fmt.Println(event) // Print the event's info.
|
||||||
|
case err := <-w.Error:
|
||||||
|
log.Fatalln(err)
|
||||||
|
case <-w.Closed:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Watch this folder for changes.
|
||||||
|
if err := w.Add("."); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch test_folder recursively for changes.
|
||||||
|
if err := w.AddRecursive("../test_folder"); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print a list of all of the files and folders currently
|
||||||
|
// being watched and their paths.
|
||||||
|
for path, f := range w.WatchedFiles() {
|
||||||
|
fmt.Printf("%s: %s\n", path, f.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
// Trigger 2 events after watcher started.
|
||||||
|
go func() {
|
||||||
|
w.Wait()
|
||||||
|
w.TriggerEvent(watcher.Create, nil)
|
||||||
|
w.TriggerEvent(watcher.Remove, nil)
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Start the watching process - it'll check for changes every 100ms.
|
||||||
|
if err := w.Start(time.Millisecond * 100); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# Contributing
|
||||||
|
If you would ike to contribute, simply submit a pull request.
|
||||||
|
|
||||||
|
# Command
|
||||||
|
|
||||||
|
`watcher` comes with a simple command which is installed when using the `go get` command from above.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage of watcher:
|
||||||
|
-cmd string
|
||||||
|
command to run when an event occurs
|
||||||
|
-dotfiles
|
||||||
|
watch dot files (default true)
|
||||||
|
-interval string
|
||||||
|
watcher poll interval (default "100ms")
|
||||||
|
-keepalive
|
||||||
|
keep alive when a cmd returns code != 0
|
||||||
|
-list
|
||||||
|
list watched files on start
|
||||||
|
-pipe
|
||||||
|
pipe event's info to command's stdin
|
||||||
|
-recursive
|
||||||
|
watch folders recursively (default true)
|
||||||
|
```
|
||||||
|
|
||||||
|
All of the flags are optional and watcher can also be called by itself:
|
||||||
|
```shell
|
||||||
|
watcher
|
||||||
|
```
|
||||||
|
(watches the current directory recursively for changes and notifies any events that occur.)
|
||||||
|
|
||||||
|
A more elaborate example using the `watcher` command:
|
||||||
|
```shell
|
||||||
|
watcher -dotfiles=false -recursive=false -cmd="./myscript" main.go ../
|
||||||
|
```
|
||||||
|
In this example, `watcher` will ignore dot files and folders and won't watch any of the specified folders recursively. It will also run the script `./myscript` anytime an event occurs while watching `main.go` or any files or folders in the previous directory (`../`).
|
||||||
|
|
||||||
|
Using the `pipe` and `cmd` flags together will send the event's info to the command's stdin when changes are detected.
|
||||||
|
|
||||||
|
First create a file called `script.py` with the following contents:
|
||||||
|
```python
|
||||||
|
import sys
|
||||||
|
|
||||||
|
for line in sys.stdin:
|
||||||
|
print (line + " - python")
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, start watcher with the `pipe` and `cmd` flags enabled:
|
||||||
|
```shell
|
||||||
|
watcher -cmd="python script.py" -pipe=true
|
||||||
|
```
|
||||||
|
|
||||||
|
Now when changes are detected, the event's info will be output from the running python script.
|
9
vendor/github.com/radovskyb/watcher/samefile.go
generated
vendored
Normal file
9
vendor/github.com/radovskyb/watcher/samefile.go
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package watcher
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
func SameFile(fi1, fi2 os.FileInfo) bool {
|
||||||
|
return os.SameFile(fi1, fi2)
|
||||||
|
}
|
12
vendor/github.com/radovskyb/watcher/samefile_windows.go
generated
vendored
Normal file
12
vendor/github.com/radovskyb/watcher/samefile_windows.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// +build windows
|
||||||
|
|
||||||
|
package watcher
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
func SameFile(fi1, fi2 os.FileInfo) bool {
|
||||||
|
return fi1.ModTime() == fi2.ModTime() &&
|
||||||
|
fi1.Size() == fi2.Size() &&
|
||||||
|
fi1.Mode() == fi2.Mode() &&
|
||||||
|
fi1.IsDir() == fi2.IsDir()
|
||||||
|
}
|
621
vendor/github.com/radovskyb/watcher/watcher.go
generated
vendored
Normal file
621
vendor/github.com/radovskyb/watcher/watcher.go
generated
vendored
Normal file
@ -0,0 +1,621 @@
|
|||||||
|
package watcher
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// ErrDurationTooShort occurs when calling the watcher's Start
|
||||||
|
// method with a duration that's less than 1 nanosecond.
|
||||||
|
ErrDurationTooShort = errors.New("error: duration is less than 1ns")
|
||||||
|
|
||||||
|
// ErrWatcherRunning occurs when trying to call the watcher's
|
||||||
|
// Start method and the polling cycle is still already running
|
||||||
|
// from previously calling Start and not yet calling Close.
|
||||||
|
ErrWatcherRunning = errors.New("error: watcher is already running")
|
||||||
|
|
||||||
|
// ErrWatchedFileDeleted is an error that occurs when a file or folder that was
|
||||||
|
// being watched has been deleted.
|
||||||
|
ErrWatchedFileDeleted = errors.New("error: watched file or folder deleted")
|
||||||
|
)
|
||||||
|
|
||||||
|
// An Op is a type that is used to describe what type
|
||||||
|
// of event has occurred during the watching process.
|
||||||
|
type Op uint32
|
||||||
|
|
||||||
|
// Ops
|
||||||
|
const (
|
||||||
|
Create Op = iota
|
||||||
|
Write
|
||||||
|
Remove
|
||||||
|
Rename
|
||||||
|
Chmod
|
||||||
|
Move
|
||||||
|
)
|
||||||
|
|
||||||
|
var ops = map[Op]string{
|
||||||
|
Create: "CREATE",
|
||||||
|
Write: "WRITE",
|
||||||
|
Remove: "REMOVE",
|
||||||
|
Rename: "RENAME",
|
||||||
|
Chmod: "CHMOD",
|
||||||
|
Move: "MOVE",
|
||||||
|
}
|
||||||
|
|
||||||
|
// String prints the string version of the Op consts
|
||||||
|
func (e Op) String() string {
|
||||||
|
if op, found := ops[e]; found {
|
||||||
|
return op
|
||||||
|
}
|
||||||
|
return "???"
|
||||||
|
}
|
||||||
|
|
||||||
|
// An Event desribes an event that is received when files or directory
|
||||||
|
// changes occur. It includes the os.FileInfo of the changed file or
|
||||||
|
// directory and the type of event that's occurred and the full path of the file.
|
||||||
|
type Event struct {
|
||||||
|
Op
|
||||||
|
Path string
|
||||||
|
os.FileInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns a string depending on what type of event occurred and the
|
||||||
|
// file name associated with the event.
|
||||||
|
func (e Event) String() string {
|
||||||
|
if e.FileInfo != nil {
|
||||||
|
pathType := "FILE"
|
||||||
|
if e.IsDir() {
|
||||||
|
pathType = "DIRECTORY"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s %q %s [%s]", pathType, e.Name(), e.Op, e.Path)
|
||||||
|
}
|
||||||
|
return "???"
|
||||||
|
}
|
||||||
|
|
||||||
|
type Watcher struct {
|
||||||
|
Event chan Event
|
||||||
|
Error chan error
|
||||||
|
Closed chan struct{}
|
||||||
|
close chan struct{}
|
||||||
|
wg *sync.WaitGroup
|
||||||
|
|
||||||
|
// mu protects the following.
|
||||||
|
mu *sync.Mutex
|
||||||
|
running bool
|
||||||
|
names map[string]bool // bool for recursive or not.
|
||||||
|
files map[string]os.FileInfo // map of files.
|
||||||
|
ignored map[string]struct{} // ignored files or directories.
|
||||||
|
ops map[Op]struct{} // Op filtering.
|
||||||
|
ignoreHidden bool // ignore hidden files or not.
|
||||||
|
maxEvents int // max sent events per cycle
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new Watcher.
|
||||||
|
func New() *Watcher {
|
||||||
|
// Set up the WaitGroup for w.Wait().
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(1)
|
||||||
|
|
||||||
|
return &Watcher{
|
||||||
|
Event: make(chan Event),
|
||||||
|
Error: make(chan error),
|
||||||
|
Closed: make(chan struct{}),
|
||||||
|
close: make(chan struct{}),
|
||||||
|
mu: new(sync.Mutex),
|
||||||
|
wg: &wg,
|
||||||
|
files: make(map[string]os.FileInfo),
|
||||||
|
ignored: make(map[string]struct{}),
|
||||||
|
names: make(map[string]bool),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMaxEvents controls the maximum amount of events that are sent on
|
||||||
|
// the Event channel per watching cycle. If max events is less than 1, there is
|
||||||
|
// no limit, which is the default.
|
||||||
|
func (w *Watcher) SetMaxEvents(delta int) {
|
||||||
|
w.mu.Lock()
|
||||||
|
w.maxEvents = delta
|
||||||
|
w.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// IgnoreHiddenFiles sets the watcher to ignore any file or directory
|
||||||
|
// that starts with a dot.
|
||||||
|
func (w *Watcher) IgnoreHiddenFiles(ignore bool) {
|
||||||
|
w.mu.Lock()
|
||||||
|
w.ignoreHidden = ignore
|
||||||
|
w.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterOps filters which event op types should be returned
|
||||||
|
// when an event occurs.
|
||||||
|
func (w *Watcher) FilterOps(ops ...Op) {
|
||||||
|
w.mu.Lock()
|
||||||
|
w.ops = make(map[Op]struct{})
|
||||||
|
for _, op := range ops {
|
||||||
|
w.ops[op] = struct{}{}
|
||||||
|
}
|
||||||
|
w.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add adds either a single file or directory to the file list.
|
||||||
|
func (w *Watcher) Add(name string) (err error) {
|
||||||
|
w.mu.Lock()
|
||||||
|
defer w.mu.Unlock()
|
||||||
|
|
||||||
|
name, err = filepath.Abs(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If name is on the ignored list or if hidden files are
|
||||||
|
// ignored and name is a hidden file or directory, simply return.
|
||||||
|
_, ignored := w.ignored[name]
|
||||||
|
if ignored || (w.ignoreHidden && strings.HasPrefix(name, ".")) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the directory's contents to the files list.
|
||||||
|
fileList, err := w.list(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for k, v := range fileList {
|
||||||
|
w.files[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the name to the names list.
|
||||||
|
w.names[name] = false
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Watcher) list(name string) (map[string]os.FileInfo, error) {
|
||||||
|
fileList := make(map[string]os.FileInfo)
|
||||||
|
|
||||||
|
// Make sure name exists.
|
||||||
|
stat, err := os.Stat(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
fileList[name] = stat
|
||||||
|
|
||||||
|
// If it's not a directory, just return.
|
||||||
|
if !stat.IsDir() {
|
||||||
|
return fileList, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's a directory.
|
||||||
|
fInfoList, err := ioutil.ReadDir(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// Add all of the files in the directory to the file list as long
|
||||||
|
// as they aren't on the ignored list or are hidden files if ignoreHidden
|
||||||
|
// is set to true.
|
||||||
|
for _, fInfo := range fInfoList {
|
||||||
|
path := filepath.Join(name, fInfo.Name())
|
||||||
|
_, ignored := w.ignored[path]
|
||||||
|
if ignored || (w.ignoreHidden && strings.HasPrefix(fInfo.Name(), ".")) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fileList[path] = fInfo
|
||||||
|
}
|
||||||
|
return fileList, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add adds either a single file or directory recursively to the file list.
|
||||||
|
func (w *Watcher) AddRecursive(name string) (err error) {
|
||||||
|
w.mu.Lock()
|
||||||
|
defer w.mu.Unlock()
|
||||||
|
|
||||||
|
name, err = filepath.Abs(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fileList, err := w.listRecursive(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for k, v := range fileList {
|
||||||
|
w.files[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the name to the names list.
|
||||||
|
w.names[name] = true
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Watcher) listRecursive(name string) (map[string]os.FileInfo, error) {
|
||||||
|
fileList := make(map[string]os.FileInfo)
|
||||||
|
|
||||||
|
return fileList, filepath.Walk(name, func(path string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// If path is ignored and it's a directory, skip the directory. If it's
|
||||||
|
// ignored and it's a single file, skip the file.
|
||||||
|
_, ignored := w.ignored[path]
|
||||||
|
if ignored || (w.ignoreHidden && strings.HasPrefix(info.Name(), ".")) {
|
||||||
|
if info.IsDir() {
|
||||||
|
return filepath.SkipDir
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// Add the path and it's info to the file list.
|
||||||
|
fileList[path] = info
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove removes either a single file or directory from the file's list.
|
||||||
|
func (w *Watcher) Remove(name string) (err error) {
|
||||||
|
w.mu.Lock()
|
||||||
|
defer w.mu.Unlock()
|
||||||
|
|
||||||
|
name, err = filepath.Abs(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the name from w's names list.
|
||||||
|
delete(w.names, name)
|
||||||
|
|
||||||
|
// If name is a single file, remove it and return.
|
||||||
|
info, found := w.files[name]
|
||||||
|
if !found {
|
||||||
|
return nil // Doesn't exist, just return.
|
||||||
|
}
|
||||||
|
if !info.IsDir() {
|
||||||
|
delete(w.files, name)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the actual directory from w.files
|
||||||
|
delete(w.files, name)
|
||||||
|
|
||||||
|
// If it's a directory, delete all of it's contents from w.files.
|
||||||
|
for path := range w.files {
|
||||||
|
if filepath.Dir(path) == name {
|
||||||
|
delete(w.files, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove removes either a single file or a directory recursively from
|
||||||
|
// the file's list.
|
||||||
|
func (w *Watcher) RemoveRecursive(name string) (err error) {
|
||||||
|
w.mu.Lock()
|
||||||
|
defer w.mu.Unlock()
|
||||||
|
|
||||||
|
name, err = filepath.Abs(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the name from w's names list.
|
||||||
|
delete(w.names, name)
|
||||||
|
|
||||||
|
// If name is a single file, remove it and return.
|
||||||
|
info, found := w.files[name]
|
||||||
|
if !found {
|
||||||
|
return nil // Doesn't exist, just return.
|
||||||
|
}
|
||||||
|
if !info.IsDir() {
|
||||||
|
delete(w.files, name)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's a directory, delete all of it's contents recursively
|
||||||
|
// from w.files.
|
||||||
|
for path := range w.files {
|
||||||
|
if strings.HasPrefix(path, name) {
|
||||||
|
delete(w.files, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore adds paths that should be ignored.
|
||||||
|
//
|
||||||
|
// For files that are already added, Ignore removes them.
|
||||||
|
func (w *Watcher) Ignore(paths ...string) (err error) {
|
||||||
|
for _, path := range paths {
|
||||||
|
path, err = filepath.Abs(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Remove any of the paths that were already added.
|
||||||
|
if err := w.RemoveRecursive(path); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w.mu.Lock()
|
||||||
|
w.ignored[path] = struct{}{}
|
||||||
|
w.mu.Unlock()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Watcher) WatchedFiles() map[string]os.FileInfo {
|
||||||
|
w.mu.Lock()
|
||||||
|
defer w.mu.Unlock()
|
||||||
|
|
||||||
|
return w.files
|
||||||
|
}
|
||||||
|
|
||||||
|
// fileInfo is an implementation of os.FileInfo that can be used
|
||||||
|
// as a mocked os.FileInfo when triggering an event when the specified
|
||||||
|
// os.FileInfo is nil.
|
||||||
|
type fileInfo struct {
|
||||||
|
name string
|
||||||
|
size int64
|
||||||
|
mode os.FileMode
|
||||||
|
modTime time.Time
|
||||||
|
sys interface{}
|
||||||
|
dir bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fs *fileInfo) IsDir() bool {
|
||||||
|
return fs.dir
|
||||||
|
}
|
||||||
|
func (fs *fileInfo) ModTime() time.Time {
|
||||||
|
return fs.modTime
|
||||||
|
}
|
||||||
|
func (fs *fileInfo) Mode() os.FileMode {
|
||||||
|
return fs.mode
|
||||||
|
}
|
||||||
|
func (fs *fileInfo) Name() string {
|
||||||
|
return fs.name
|
||||||
|
}
|
||||||
|
func (fs *fileInfo) Size() int64 {
|
||||||
|
return fs.size
|
||||||
|
}
|
||||||
|
func (fs *fileInfo) Sys() interface{} {
|
||||||
|
return fs.sys
|
||||||
|
}
|
||||||
|
|
||||||
|
// TriggerEvent is a method that can be used to trigger an event, separate to
|
||||||
|
// the file watching process.
|
||||||
|
func (w *Watcher) TriggerEvent(eventType Op, file os.FileInfo) {
|
||||||
|
w.Wait()
|
||||||
|
if file == nil {
|
||||||
|
file = &fileInfo{name: "triggered event", modTime: time.Now()}
|
||||||
|
}
|
||||||
|
w.Event <- Event{Op: eventType, Path: "-", FileInfo: file}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Watcher) retrieveFileList() map[string]os.FileInfo {
|
||||||
|
w.mu.Lock()
|
||||||
|
defer w.mu.Unlock()
|
||||||
|
|
||||||
|
fileList := make(map[string]os.FileInfo)
|
||||||
|
|
||||||
|
var list map[string]os.FileInfo
|
||||||
|
var err error
|
||||||
|
|
||||||
|
for name, recursive := range w.names {
|
||||||
|
if recursive {
|
||||||
|
list, err = w.listRecursive(name)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
w.Error <- ErrWatchedFileDeleted
|
||||||
|
w.mu.Unlock()
|
||||||
|
w.RemoveRecursive(name)
|
||||||
|
w.mu.Lock()
|
||||||
|
} else {
|
||||||
|
w.Error <- err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list, err = w.list(name)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
w.Error <- ErrWatchedFileDeleted
|
||||||
|
w.mu.Unlock()
|
||||||
|
w.Remove(name)
|
||||||
|
w.mu.Lock()
|
||||||
|
} else {
|
||||||
|
w.Error <- err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add the file's to the file list.
|
||||||
|
for k, v := range list {
|
||||||
|
fileList[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileList
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start begins the polling cycle which repeats every specified
|
||||||
|
// duration until Close is called.
|
||||||
|
func (w *Watcher) Start(d time.Duration) error {
|
||||||
|
// Return an error if d is less than 1 nanosecond.
|
||||||
|
if d < time.Nanosecond {
|
||||||
|
return ErrDurationTooShort
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the Watcher is not already running.
|
||||||
|
w.mu.Lock()
|
||||||
|
if w.running {
|
||||||
|
w.mu.Unlock()
|
||||||
|
return ErrWatcherRunning
|
||||||
|
}
|
||||||
|
w.running = true
|
||||||
|
w.mu.Unlock()
|
||||||
|
|
||||||
|
// Unblock w.Wait().
|
||||||
|
w.wg.Done()
|
||||||
|
|
||||||
|
for {
|
||||||
|
// done lets the inner polling cycle loop know when the
|
||||||
|
// current cycle's method has finished executing.
|
||||||
|
done := make(chan struct{})
|
||||||
|
|
||||||
|
// Any events that are found are first piped to evt before
|
||||||
|
// being sent to the main Event channel.
|
||||||
|
evt := make(chan Event)
|
||||||
|
|
||||||
|
// Retrieve the file list for all watched file's and dirs.
|
||||||
|
fileList := w.retrieveFileList()
|
||||||
|
|
||||||
|
// cancel can be used to cancel the current event polling function.
|
||||||
|
cancel := make(chan struct{})
|
||||||
|
|
||||||
|
// Look for events.
|
||||||
|
go func() {
|
||||||
|
w.pollEvents(fileList, evt, cancel)
|
||||||
|
done <- struct{}{}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// numEvents holds the number of events for the current cycle.
|
||||||
|
numEvents := 0
|
||||||
|
|
||||||
|
inner:
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-w.close:
|
||||||
|
close(cancel)
|
||||||
|
close(w.Closed)
|
||||||
|
return nil
|
||||||
|
case event := <-evt:
|
||||||
|
if len(w.ops) > 0 { // Filter Ops.
|
||||||
|
_, found := w.ops[event.Op]
|
||||||
|
if !found {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
numEvents++
|
||||||
|
if w.maxEvents > 0 && numEvents > w.maxEvents {
|
||||||
|
close(cancel)
|
||||||
|
break inner
|
||||||
|
}
|
||||||
|
w.Event <- event
|
||||||
|
case <-done: // Current cycle is finished.
|
||||||
|
break inner
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the file's list.
|
||||||
|
w.mu.Lock()
|
||||||
|
w.files = fileList
|
||||||
|
w.mu.Unlock()
|
||||||
|
|
||||||
|
// Sleep and then continue to the next loop iteration.
|
||||||
|
time.Sleep(d)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Watcher) pollEvents(files map[string]os.FileInfo, evt chan Event,
|
||||||
|
cancel chan struct{}) {
|
||||||
|
w.mu.Lock()
|
||||||
|
defer w.mu.Unlock()
|
||||||
|
|
||||||
|
// Store create and remove events for use to check for rename events.
|
||||||
|
creates := make(map[string]os.FileInfo)
|
||||||
|
removes := make(map[string]os.FileInfo)
|
||||||
|
|
||||||
|
// Check for removed files.
|
||||||
|
for path, info := range w.files {
|
||||||
|
if _, found := files[path]; !found {
|
||||||
|
removes[path] = info
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for created files, writes and chmods.
|
||||||
|
for path, info := range files {
|
||||||
|
oldInfo, found := w.files[path]
|
||||||
|
if !found {
|
||||||
|
// A file was created.
|
||||||
|
creates[path] = info
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if oldInfo.ModTime() != info.ModTime() {
|
||||||
|
select {
|
||||||
|
case <-cancel:
|
||||||
|
return
|
||||||
|
case evt <- Event{Write, path, info}:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if oldInfo.Mode() != info.Mode() {
|
||||||
|
select {
|
||||||
|
case <-cancel:
|
||||||
|
return
|
||||||
|
case evt <- Event{Chmod, path, info}:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for renames and moves.
|
||||||
|
for path1, info1 := range removes {
|
||||||
|
for path2, info2 := range creates {
|
||||||
|
if SameFile(info1, info2) {
|
||||||
|
e := Event{
|
||||||
|
Op: Move,
|
||||||
|
Path: fmt.Sprintf("%s -> %s", path1, path2),
|
||||||
|
FileInfo: info1,
|
||||||
|
}
|
||||||
|
// If they are from the same directory, it's a rename
|
||||||
|
// instead of a move event.
|
||||||
|
if filepath.Dir(path1) == filepath.Dir(path2) {
|
||||||
|
e.Op = Rename
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(removes, path1)
|
||||||
|
delete(creates, path2)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-cancel:
|
||||||
|
return
|
||||||
|
case evt <- e:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send all the remaining create and remove events.
|
||||||
|
for path, info := range creates {
|
||||||
|
select {
|
||||||
|
case <-cancel:
|
||||||
|
return
|
||||||
|
case evt <- Event{Create, path, info}:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for path, info := range removes {
|
||||||
|
select {
|
||||||
|
case <-cancel:
|
||||||
|
return
|
||||||
|
case evt <- Event{Remove, path, info}:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait blocks until the watcher is started.
|
||||||
|
func (w *Watcher) Wait() {
|
||||||
|
w.wg.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Watcher) Close() {
|
||||||
|
w.mu.Lock()
|
||||||
|
if !w.running {
|
||||||
|
w.mu.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.running = false
|
||||||
|
w.files = make(map[string]os.FileInfo)
|
||||||
|
w.names = make(map[string]bool)
|
||||||
|
w.mu.Unlock()
|
||||||
|
// Send a close signal to the Start method.
|
||||||
|
w.close <- struct{}{}
|
||||||
|
}
|
10
vendor/golang.org/x/sys/.gitattributes
generated
vendored
10
vendor/golang.org/x/sys/.gitattributes
generated
vendored
@ -1,10 +0,0 @@
|
|||||||
# Treat all files in this repo as binary, with no git magic updating
|
|
||||||
# line endings. Windows users contributing to Go will need to use a
|
|
||||||
# modern version of git and editors capable of LF line endings.
|
|
||||||
#
|
|
||||||
# We'll prevent accidental CRLF line endings from entering the repo
|
|
||||||
# via the git-review gofmt checks.
|
|
||||||
#
|
|
||||||
# See golang.org/issue/9281
|
|
||||||
|
|
||||||
* -text
|
|
2
vendor/golang.org/x/sys/.gitignore
generated
vendored
2
vendor/golang.org/x/sys/.gitignore
generated
vendored
@ -1,2 +0,0 @@
|
|||||||
# Add no patterns to .hgignore except for files generated by the build.
|
|
||||||
last-change
|
|
3
vendor/golang.org/x/sys/AUTHORS
generated
vendored
3
vendor/golang.org/x/sys/AUTHORS
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# This source code refers to The Go Authors for copyright purposes.
|
|
||||||
# The master list of authors is in the main Go distribution,
|
|
||||||
# visible at http://tip.golang.org/AUTHORS.
|
|
31
vendor/golang.org/x/sys/CONTRIBUTING.md
generated
vendored
31
vendor/golang.org/x/sys/CONTRIBUTING.md
generated
vendored
@ -1,31 +0,0 @@
|
|||||||
# Contributing to Go
|
|
||||||
|
|
||||||
Go is an open source project.
|
|
||||||
|
|
||||||
It is the work of hundreds of contributors. We appreciate your help!
|
|
||||||
|
|
||||||
|
|
||||||
## Filing issues
|
|
||||||
|
|
||||||
When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions:
|
|
||||||
|
|
||||||
1. What version of Go are you using (`go version`)?
|
|
||||||
2. What operating system and processor architecture are you using?
|
|
||||||
3. What did you do?
|
|
||||||
4. What did you expect to see?
|
|
||||||
5. What did you see instead?
|
|
||||||
|
|
||||||
General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker.
|
|
||||||
The gophers there will answer or ask you to file an issue if you've tripped over a bug.
|
|
||||||
|
|
||||||
## Contributing code
|
|
||||||
|
|
||||||
Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html)
|
|
||||||
before sending patches.
|
|
||||||
|
|
||||||
**We do not accept GitHub pull requests**
|
|
||||||
(we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review).
|
|
||||||
|
|
||||||
Unless otherwise noted, the Go source files are distributed under
|
|
||||||
the BSD-style license found in the LICENSE file.
|
|
||||||
|
|
3
vendor/golang.org/x/sys/CONTRIBUTORS
generated
vendored
3
vendor/golang.org/x/sys/CONTRIBUTORS
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# This source code was written by the Go contributors.
|
|
||||||
# The master list of contributors is in the main Go distribution,
|
|
||||||
# visible at http://tip.golang.org/CONTRIBUTORS.
|
|
27
vendor/golang.org/x/sys/LICENSE
generated
vendored
27
vendor/golang.org/x/sys/LICENSE
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22
vendor/golang.org/x/sys/PATENTS
generated
vendored
22
vendor/golang.org/x/sys/PATENTS
generated
vendored
@ -1,22 +0,0 @@
|
|||||||
Additional IP Rights Grant (Patents)
|
|
||||||
|
|
||||||
"This implementation" means the copyrightable works distributed by
|
|
||||||
Google as part of the Go project.
|
|
||||||
|
|
||||||
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
||||||
no-charge, royalty-free, irrevocable (except as stated in this section)
|
|
||||||
patent license to make, have made, use, offer to sell, sell, import,
|
|
||||||
transfer and otherwise run, modify and propagate the contents of this
|
|
||||||
implementation of Go, where such license applies only to those patent
|
|
||||||
claims, both currently owned or controlled by Google and acquired in
|
|
||||||
the future, licensable by Google that are necessarily infringed by this
|
|
||||||
implementation of Go. This grant does not include claims that would be
|
|
||||||
infringed only as a consequence of further modification of this
|
|
||||||
implementation. If you or your agent or exclusive licensee institute or
|
|
||||||
order or agree to the institution of patent litigation against any
|
|
||||||
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
|
||||||
that this implementation of Go or any code incorporated within this
|
|
||||||
implementation of Go constitutes direct or contributory patent
|
|
||||||
infringement, or inducement of patent infringement, then any patent
|
|
||||||
rights granted to you under this License for this implementation of Go
|
|
||||||
shall terminate as of the date such litigation is filed.
|
|
3
vendor/golang.org/x/sys/README
generated
vendored
3
vendor/golang.org/x/sys/README
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
This repository holds supplemental Go packages for low-level interactions with the operating system.
|
|
||||||
|
|
||||||
To submit changes to this repository, see http://golang.org/doc/contribute.html.
|
|
1
vendor/golang.org/x/sys/codereview.cfg
generated
vendored
1
vendor/golang.org/x/sys/codereview.cfg
generated
vendored
@ -1 +0,0 @@
|
|||||||
issuerepo: golang/go
|
|
1
vendor/golang.org/x/sys/unix/.gitignore
generated
vendored
1
vendor/golang.org/x/sys/unix/.gitignore
generated
vendored
@ -1 +0,0 @@
|
|||||||
_obj/
|
|
173
vendor/golang.org/x/sys/unix/README.md
generated
vendored
173
vendor/golang.org/x/sys/unix/README.md
generated
vendored
@ -1,173 +0,0 @@
|
|||||||
# Building `sys/unix`
|
|
||||||
|
|
||||||
The sys/unix package provides access to the raw system call interface of the
|
|
||||||
underlying operating system. See: https://godoc.org/golang.org/x/sys/unix
|
|
||||||
|
|
||||||
Porting Go to a new architecture/OS combination or adding syscalls, types, or
|
|
||||||
constants to an existing architecture/OS pair requires some manual effort;
|
|
||||||
however, there are tools that automate much of the process.
|
|
||||||
|
|
||||||
## Build Systems
|
|
||||||
|
|
||||||
There are currently two ways we generate the necessary files. We are currently
|
|
||||||
migrating the build system to use containers so the builds are reproducible.
|
|
||||||
This is being done on an OS-by-OS basis. Please update this documentation as
|
|
||||||
components of the build system change.
|
|
||||||
|
|
||||||
### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`)
|
|
||||||
|
|
||||||
The old build system generates the Go files based on the C header files
|
|
||||||
present on your system. This means that files
|
|
||||||
for a given GOOS/GOARCH pair must be generated on a system with that OS and
|
|
||||||
architecture. This also means that the generated code can differ from system
|
|
||||||
to system, based on differences in the header files.
|
|
||||||
|
|
||||||
To avoid this, if you are using the old build system, only generate the Go
|
|
||||||
files on an installation with unmodified header files. It is also important to
|
|
||||||
keep track of which version of the OS the files were generated from (ex.
|
|
||||||
Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes
|
|
||||||
and have each OS upgrade correspond to a single change.
|
|
||||||
|
|
||||||
To build the files for your current OS and architecture, make sure GOOS and
|
|
||||||
GOARCH are set correctly and run `mkall.sh`. This will generate the files for
|
|
||||||
your specific system. Running `mkall.sh -n` shows the commands that will be run.
|
|
||||||
|
|
||||||
Requirements: bash, perl, go
|
|
||||||
|
|
||||||
### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`)
|
|
||||||
|
|
||||||
The new build system uses a Docker container to generate the go files directly
|
|
||||||
from source checkouts of the kernel and various system libraries. This means
|
|
||||||
that on any platform that supports Docker, all the files using the new build
|
|
||||||
system can be generated at once, and generated files will not change based on
|
|
||||||
what the person running the scripts has installed on their computer.
|
|
||||||
|
|
||||||
The OS specific files for the new build system are located in the `${GOOS}`
|
|
||||||
directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When
|
|
||||||
the kernel or system library updates, modify the Dockerfile at
|
|
||||||
`${GOOS}/Dockerfile` to checkout the new release of the source.
|
|
||||||
|
|
||||||
To build all the files under the new build system, you must be on an amd64/Linux
|
|
||||||
system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
|
|
||||||
then generate all of the files for all of the GOOS/GOARCH pairs in the new build
|
|
||||||
system. Running `mkall.sh -n` shows the commands that will be run.
|
|
||||||
|
|
||||||
Requirements: bash, perl, go, docker
|
|
||||||
|
|
||||||
## Component files
|
|
||||||
|
|
||||||
This section describes the various files used in the code generation process.
|
|
||||||
It also contains instructions on how to modify these files to add a new
|
|
||||||
architecture/OS or to add additional syscalls, types, or constants. Note that
|
|
||||||
if you are using the new build system, the scripts cannot be called normally.
|
|
||||||
They must be called from within the docker container.
|
|
||||||
|
|
||||||
### asm files
|
|
||||||
|
|
||||||
The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system
|
|
||||||
call dispatch. There are three entry points:
|
|
||||||
```
|
|
||||||
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
|
|
||||||
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
|
|
||||||
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
|
|
||||||
```
|
|
||||||
The first and second are the standard ones; they differ only in how many
|
|
||||||
arguments can be passed to the kernel. The third is for low-level use by the
|
|
||||||
ForkExec wrapper. Unlike the first two, it does not call into the scheduler to
|
|
||||||
let it know that a system call is running.
|
|
||||||
|
|
||||||
When porting Go to an new architecture/OS, this file must be implemented for
|
|
||||||
each GOOS/GOARCH pair.
|
|
||||||
|
|
||||||
### mksysnum
|
|
||||||
|
|
||||||
Mksysnum is a script located at `${GOOS}/mksysnum.pl` (or `mksysnum_${GOOS}.pl`
|
|
||||||
for the old system). This script takes in a list of header files containing the
|
|
||||||
syscall number declarations and parses them to produce the corresponding list of
|
|
||||||
Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
|
|
||||||
constants.
|
|
||||||
|
|
||||||
Adding new syscall numbers is mostly done by running the build on a sufficiently
|
|
||||||
new installation of the target OS (or updating the source checkouts for the
|
|
||||||
new build system). However, depending on the OS, you make need to update the
|
|
||||||
parsing in mksysnum.
|
|
||||||
|
|
||||||
### mksyscall.pl
|
|
||||||
|
|
||||||
The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
|
|
||||||
hand-written Go files which implement system calls (for unix, the specific OS,
|
|
||||||
or the specific OS/Architecture pair respectively) that need special handling
|
|
||||||
and list `//sys` comments giving prototypes for ones that can be generated.
|
|
||||||
|
|
||||||
The mksyscall.pl script takes the `//sys` and `//sysnb` comments and converts
|
|
||||||
them into syscalls. This requires the name of the prototype in the comment to
|
|
||||||
match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
|
|
||||||
prototype can be exported (capitalized) or not.
|
|
||||||
|
|
||||||
Adding a new syscall often just requires adding a new `//sys` function prototype
|
|
||||||
with the desired arguments and a capitalized name so it is exported. However, if
|
|
||||||
you want the interface to the syscall to be different, often one will make an
|
|
||||||
unexported `//sys` prototype, an then write a custom wrapper in
|
|
||||||
`syscall_${GOOS}.go`.
|
|
||||||
|
|
||||||
### types files
|
|
||||||
|
|
||||||
For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or
|
|
||||||
`types_${GOOS}.go` on the old system). This file includes standard C headers and
|
|
||||||
creates Go type aliases to the corresponding C types. The file is then fed
|
|
||||||
through godef to get the Go compatible definitions. Finally, the generated code
|
|
||||||
is fed though mkpost.go to format the code correctly and remove any hidden or
|
|
||||||
private identifiers. This cleaned-up code is written to
|
|
||||||
`ztypes_${GOOS}_${GOARCH}.go`.
|
|
||||||
|
|
||||||
The hardest part about preparing this file is figuring out which headers to
|
|
||||||
include and which symbols need to be `#define`d to get the actual data
|
|
||||||
structures that pass through to the kernel system calls. Some C libraries
|
|
||||||
preset alternate versions for binary compatibility and translate them on the
|
|
||||||
way in and out of system calls, but there is almost always a `#define` that can
|
|
||||||
get the real ones.
|
|
||||||
See `types_darwin.go` and `linux/types.go` for examples.
|
|
||||||
|
|
||||||
To add a new type, add in the necessary include statement at the top of the
|
|
||||||
file (if it is not already there) and add in a type alias line. Note that if
|
|
||||||
your type is significantly different on different architectures, you may need
|
|
||||||
some `#if/#elif` macros in your include statements.
|
|
||||||
|
|
||||||
### mkerrors.sh
|
|
||||||
|
|
||||||
This script is used to generate the system's various constants. This doesn't
|
|
||||||
just include the error numbers and error strings, but also the signal numbers
|
|
||||||
an a wide variety of miscellaneous constants. The constants come from the list
|
|
||||||
of include files in the `includes_${uname}` variable. A regex then picks out
|
|
||||||
the desired `#define` statements, and generates the corresponding Go constants.
|
|
||||||
The error numbers and strings are generated from `#include <errno.h>`, and the
|
|
||||||
signal numbers and strings are generated from `#include <signal.h>`. All of
|
|
||||||
these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program,
|
|
||||||
`_errors.c`, which prints out all the constants.
|
|
||||||
|
|
||||||
To add a constant, add the header that includes it to the appropriate variable.
|
|
||||||
Then, edit the regex (if necessary) to match the desired constant. Avoid making
|
|
||||||
the regex too broad to avoid matching unintended constants.
|
|
||||||
|
|
||||||
|
|
||||||
## Generated files
|
|
||||||
|
|
||||||
### `zerror_${GOOS}_${GOARCH}.go`
|
|
||||||
|
|
||||||
A file containing all of the system's generated error numbers, error strings,
|
|
||||||
signal numbers, and constants. Generated by `mkerrors.sh` (see above).
|
|
||||||
|
|
||||||
### `zsyscall_${GOOS}_${GOARCH}.go`
|
|
||||||
|
|
||||||
A file containing all the generated syscalls for a specific GOOS and GOARCH.
|
|
||||||
Generated by `mksyscall.pl` (see above).
|
|
||||||
|
|
||||||
### `zsysnum_${GOOS}_${GOARCH}.go`
|
|
||||||
|
|
||||||
A list of numeric constants for all the syscall number of the specific GOOS
|
|
||||||
and GOARCH. Generated by mksysnum (see above).
|
|
||||||
|
|
||||||
### `ztypes_${GOOS}_${GOARCH}.go`
|
|
||||||
|
|
||||||
A file containing Go types for passing into (or returning from) syscalls.
|
|
||||||
Generated by godefs and the types file (see above).
|
|
29
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for 386, Darwin
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for AMD64, Darwin
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
30
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
30
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
// +build arm,darwin
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for ARM, Darwin
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
B syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
B syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
|
||||||
B syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
B syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
B syscall·RawSyscall6(SB)
|
|
30
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
30
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
// +build arm64,darwin
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for AMD64, Darwin
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
B syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
B syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
|
||||||
B syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
B syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
B syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for AMD64, DragonFly
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-64
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-88
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-112
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-64
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-88
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for 386, FreeBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for AMD64, FreeBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2012 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for ARM, FreeBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
B syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
B syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
|
||||||
B syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
B syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
B syscall·RawSyscall6(SB)
|
|
35
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
35
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
@ -1,35 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System calls for 386, Linux
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·socketcall(SB),NOSPLIT,$0-36
|
|
||||||
JMP syscall·socketcall(SB)
|
|
||||||
|
|
||||||
TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
|
|
||||||
JMP syscall·rawsocketcall(SB)
|
|
||||||
|
|
||||||
TEXT ·seek(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·seek(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System calls for AMD64, Linux
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·gettimeofday(SB),NOSPLIT,$0-16
|
|
||||||
JMP syscall·gettimeofday(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System calls for arm, Linux
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
B syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
B syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
B syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
B syscall·RawSyscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·seek(SB),NOSPLIT,$0-32
|
|
||||||
B syscall·seek(SB)
|
|
24
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
24
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
@ -1,24 +0,0 @@
|
|||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build linux
|
|
||||||
// +build arm64
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
B syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
B syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
B syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
B syscall·RawSyscall6(SB)
|
|
28
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
28
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
@ -1,28 +0,0 @@
|
|||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build linux
|
|
||||||
// +build mips64 mips64le
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System calls for mips64, Linux
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
31
vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
generated
vendored
31
vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
generated
vendored
@ -1,31 +0,0 @@
|
|||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build linux
|
|
||||||
// +build mips mipsle
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System calls for mips, Linux
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
28
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
28
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
@ -1,28 +0,0 @@
|
|||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build linux
|
|
||||||
// +build ppc64 ppc64le
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System calls for ppc64, Linux
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
BR syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
BR syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
BR syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
BR syscall·RawSyscall6(SB)
|
|
28
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
28
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
@ -1,28 +0,0 @@
|
|||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build s390x
|
|
||||||
// +build linux
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System calls for s390x, Linux
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
BR syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
BR syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
BR syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
BR syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for 386, NetBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for AMD64, NetBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2013 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for ARM, NetBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
B syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
B syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
|
||||||
B syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
B syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
B syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for 386, OpenBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for AMD64, OpenBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
17
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
17
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
@ -1,17 +0,0 @@
|
|||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build !gccgo
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
|
|
||||||
//
|
|
||||||
|
|
||||||
TEXT ·sysvicall6(SB),NOSPLIT,$0-88
|
|
||||||
JMP syscall·sysvicall6(SB)
|
|
||||||
|
|
||||||
TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88
|
|
||||||
JMP syscall·rawSysvicall6(SB)
|
|
35
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
35
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
@ -1,35 +0,0 @@
|
|||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Bluetooth sockets and messages
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
// Bluetooth Protocols
|
|
||||||
const (
|
|
||||||
BTPROTO_L2CAP = 0
|
|
||||||
BTPROTO_HCI = 1
|
|
||||||
BTPROTO_SCO = 2
|
|
||||||
BTPROTO_RFCOMM = 3
|
|
||||||
BTPROTO_BNEP = 4
|
|
||||||
BTPROTO_CMTP = 5
|
|
||||||
BTPROTO_HIDP = 6
|
|
||||||
BTPROTO_AVDTP = 7
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
HCI_CHANNEL_RAW = 0
|
|
||||||
HCI_CHANNEL_USER = 1
|
|
||||||
HCI_CHANNEL_MONITOR = 2
|
|
||||||
HCI_CHANNEL_CONTROL = 3
|
|
||||||
)
|
|
||||||
|
|
||||||
// Socketoption Level
|
|
||||||
const (
|
|
||||||
SOL_BLUETOOTH = 0x112
|
|
||||||
SOL_HCI = 0x0
|
|
||||||
SOL_L2CAP = 0x6
|
|
||||||
SOL_RFCOMM = 0x12
|
|
||||||
SOL_SCO = 0x11
|
|
||||||
)
|
|
195
vendor/golang.org/x/sys/unix/cap_freebsd.go
generated
vendored
195
vendor/golang.org/x/sys/unix/cap_freebsd.go
generated
vendored
@ -1,195 +0,0 @@
|
|||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build freebsd
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import (
|
|
||||||
errorspkg "errors"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
|
|
||||||
|
|
||||||
const (
|
|
||||||
// This is the version of CapRights this package understands. See C implementation for parallels.
|
|
||||||
capRightsGoVersion = CAP_RIGHTS_VERSION_00
|
|
||||||
capArSizeMin = CAP_RIGHTS_VERSION_00 + 2
|
|
||||||
capArSizeMax = capRightsGoVersion + 2
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
bit2idx = []int{
|
|
||||||
-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1,
|
|
||||||
4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func capidxbit(right uint64) int {
|
|
||||||
return int((right >> 57) & 0x1f)
|
|
||||||
}
|
|
||||||
|
|
||||||
func rightToIndex(right uint64) (int, error) {
|
|
||||||
idx := capidxbit(right)
|
|
||||||
if idx < 0 || idx >= len(bit2idx) {
|
|
||||||
return -2, fmt.Errorf("index for right 0x%x out of range", right)
|
|
||||||
}
|
|
||||||
return bit2idx[idx], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func caprver(right uint64) int {
|
|
||||||
return int(right >> 62)
|
|
||||||
}
|
|
||||||
|
|
||||||
func capver(rights *CapRights) int {
|
|
||||||
return caprver(rights.Rights[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
func caparsize(rights *CapRights) int {
|
|
||||||
return capver(rights) + 2
|
|
||||||
}
|
|
||||||
|
|
||||||
// CapRightsSet sets the permissions in setrights in rights.
|
|
||||||
func CapRightsSet(rights *CapRights, setrights []uint64) error {
|
|
||||||
// This is essentially a copy of cap_rights_vset()
|
|
||||||
if capver(rights) != CAP_RIGHTS_VERSION_00 {
|
|
||||||
return fmt.Errorf("bad rights version %d", capver(rights))
|
|
||||||
}
|
|
||||||
|
|
||||||
n := caparsize(rights)
|
|
||||||
if n < capArSizeMin || n > capArSizeMax {
|
|
||||||
return errorspkg.New("bad rights size")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, right := range setrights {
|
|
||||||
if caprver(right) != CAP_RIGHTS_VERSION_00 {
|
|
||||||
return errorspkg.New("bad right version")
|
|
||||||
}
|
|
||||||
i, err := rightToIndex(right)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if i >= n {
|
|
||||||
return errorspkg.New("index overflow")
|
|
||||||
}
|
|
||||||
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
|
||||||
return errorspkg.New("index mismatch")
|
|
||||||
}
|
|
||||||
rights.Rights[i] |= right
|
|
||||||
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
|
||||||
return errorspkg.New("index mismatch (after assign)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CapRightsClear clears the permissions in clearrights from rights.
|
|
||||||
func CapRightsClear(rights *CapRights, clearrights []uint64) error {
|
|
||||||
// This is essentially a copy of cap_rights_vclear()
|
|
||||||
if capver(rights) != CAP_RIGHTS_VERSION_00 {
|
|
||||||
return fmt.Errorf("bad rights version %d", capver(rights))
|
|
||||||
}
|
|
||||||
|
|
||||||
n := caparsize(rights)
|
|
||||||
if n < capArSizeMin || n > capArSizeMax {
|
|
||||||
return errorspkg.New("bad rights size")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, right := range clearrights {
|
|
||||||
if caprver(right) != CAP_RIGHTS_VERSION_00 {
|
|
||||||
return errorspkg.New("bad right version")
|
|
||||||
}
|
|
||||||
i, err := rightToIndex(right)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if i >= n {
|
|
||||||
return errorspkg.New("index overflow")
|
|
||||||
}
|
|
||||||
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
|
||||||
return errorspkg.New("index mismatch")
|
|
||||||
}
|
|
||||||
rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
|
|
||||||
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
|
||||||
return errorspkg.New("index mismatch (after assign)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
|
|
||||||
func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
|
|
||||||
// This is essentially a copy of cap_rights_is_vset()
|
|
||||||
if capver(rights) != CAP_RIGHTS_VERSION_00 {
|
|
||||||
return false, fmt.Errorf("bad rights version %d", capver(rights))
|
|
||||||
}
|
|
||||||
|
|
||||||
n := caparsize(rights)
|
|
||||||
if n < capArSizeMin || n > capArSizeMax {
|
|
||||||
return false, errorspkg.New("bad rights size")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, right := range setrights {
|
|
||||||
if caprver(right) != CAP_RIGHTS_VERSION_00 {
|
|
||||||
return false, errorspkg.New("bad right version")
|
|
||||||
}
|
|
||||||
i, err := rightToIndex(right)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
if i >= n {
|
|
||||||
return false, errorspkg.New("index overflow")
|
|
||||||
}
|
|
||||||
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
|
||||||
return false, errorspkg.New("index mismatch")
|
|
||||||
}
|
|
||||||
if (rights.Rights[i] & right) != right {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func capright(idx uint64, bit uint64) uint64 {
|
|
||||||
return ((1 << (57 + idx)) | bit)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
|
|
||||||
// See man cap_rights_init(3) and rights(4).
|
|
||||||
func CapRightsInit(rights []uint64) (*CapRights, error) {
|
|
||||||
var r CapRights
|
|
||||||
r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0)
|
|
||||||
r.Rights[1] = capright(1, 0)
|
|
||||||
|
|
||||||
err := CapRightsSet(&r, rights)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &r, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
|
|
||||||
// The capability rights on fd can never be increased by CapRightsLimit.
|
|
||||||
// See man cap_rights_limit(2) and rights(4).
|
|
||||||
func CapRightsLimit(fd uintptr, rights *CapRights) error {
|
|
||||||
return capRightsLimit(int(fd), rights)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
|
|
||||||
// See man cap_rights_get(3) and rights(4).
|
|
||||||
func CapRightsGet(fd uintptr) (*CapRights, error) {
|
|
||||||
r, err := CapRightsInit(nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
err = capRightsGet(capRightsGoVersion, int(fd), r)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return r, nil
|
|
||||||
}
|
|
13
vendor/golang.org/x/sys/unix/constants.go
generated
vendored
13
vendor/golang.org/x/sys/unix/constants.go
generated
vendored
@ -1,13 +0,0 @@
|
|||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
R_OK = 0x4
|
|
||||||
W_OK = 0x2
|
|
||||||
X_OK = 0x1
|
|
||||||
)
|
|
42
vendor/golang.org/x/sys/unix/dev_linux.go
generated
vendored
42
vendor/golang.org/x/sys/unix/dev_linux.go
generated
vendored
@ -1,42 +0,0 @@
|
|||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Functions to access/create device major and minor numbers matching the
|
|
||||||
// encoding used by the Linux kernel and glibc.
|
|
||||||
//
|
|
||||||
// The information below is extracted and adapted from bits/sysmacros.h in the
|
|
||||||
// glibc sources:
|
|
||||||
//
|
|
||||||
// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
|
|
||||||
// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
|
|
||||||
// number and m is a hex digit of the minor number. This is backward compatible
|
|
||||||
// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
|
|
||||||
// backward compatible with the Linux kernel, which for some architectures uses
|
|
||||||
// 32-bit dev_t, encoded as mmmM MMmm.
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
// Major returns the major component of a Linux device number.
|
|
||||||
func Major(dev uint64) uint32 {
|
|
||||||
major := uint32((dev & 0x00000000000fff00) >> 8)
|
|
||||||
major |= uint32((dev & 0xfffff00000000000) >> 32)
|
|
||||||
return major
|
|
||||||
}
|
|
||||||
|
|
||||||
// Minor returns the minor component of a Linux device number.
|
|
||||||
func Minor(dev uint64) uint32 {
|
|
||||||
minor := uint32((dev & 0x00000000000000ff) >> 0)
|
|
||||||
minor |= uint32((dev & 0x00000ffffff00000) >> 12)
|
|
||||||
return minor
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mkdev returns a Linux device number generated from the given major and minor
|
|
||||||
// components.
|
|
||||||
func Mkdev(major, minor uint32) uint64 {
|
|
||||||
dev := uint64((major & 0x00000fff) << 8)
|
|
||||||
dev |= uint64((major & 0xfffff000) << 32)
|
|
||||||
dev |= uint64((minor & 0x000000ff) << 0)
|
|
||||||
dev |= uint64((minor & 0xffffff00) << 12)
|
|
||||||
return dev
|
|
||||||
}
|
|
102
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
102
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
@ -1,102 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "unsafe"
|
|
||||||
|
|
||||||
// readInt returns the size-bytes unsigned integer in native byte order at offset off.
|
|
||||||
func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
|
|
||||||
if len(b) < int(off+size) {
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
if isBigEndian {
|
|
||||||
return readIntBE(b[off:], size), true
|
|
||||||
}
|
|
||||||
return readIntLE(b[off:], size), true
|
|
||||||
}
|
|
||||||
|
|
||||||
func readIntBE(b []byte, size uintptr) uint64 {
|
|
||||||
switch size {
|
|
||||||
case 1:
|
|
||||||
return uint64(b[0])
|
|
||||||
case 2:
|
|
||||||
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[1]) | uint64(b[0])<<8
|
|
||||||
case 4:
|
|
||||||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
|
|
||||||
case 8:
|
|
||||||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
|
|
||||||
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
|
|
||||||
default:
|
|
||||||
panic("syscall: readInt with unsupported size")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func readIntLE(b []byte, size uintptr) uint64 {
|
|
||||||
switch size {
|
|
||||||
case 1:
|
|
||||||
return uint64(b[0])
|
|
||||||
case 2:
|
|
||||||
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[0]) | uint64(b[1])<<8
|
|
||||||
case 4:
|
|
||||||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
|
|
||||||
case 8:
|
|
||||||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
|
|
||||||
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
|
|
||||||
default:
|
|
||||||
panic("syscall: readInt with unsupported size")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseDirent parses up to max directory entries in buf,
|
|
||||||
// appending the names to names. It returns the number of
|
|
||||||
// bytes consumed from buf, the number of entries added
|
|
||||||
// to names, and the new names slice.
|
|
||||||
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
|
||||||
origlen := len(buf)
|
|
||||||
count = 0
|
|
||||||
for max != 0 && len(buf) > 0 {
|
|
||||||
reclen, ok := direntReclen(buf)
|
|
||||||
if !ok || reclen > uint64(len(buf)) {
|
|
||||||
return origlen, count, names
|
|
||||||
}
|
|
||||||
rec := buf[:reclen]
|
|
||||||
buf = buf[reclen:]
|
|
||||||
ino, ok := direntIno(rec)
|
|
||||||
if !ok {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if ino == 0 { // File absent in directory.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
|
|
||||||
namlen, ok := direntNamlen(rec)
|
|
||||||
if !ok || namoff+namlen > uint64(len(rec)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
name := rec[namoff : namoff+namlen]
|
|
||||||
for i, c := range name {
|
|
||||||
if c == 0 {
|
|
||||||
name = name[:i]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check for useless names before allocating a string.
|
|
||||||
if string(name) == "." || string(name) == ".." {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
max--
|
|
||||||
count++
|
|
||||||
names = append(names, string(name))
|
|
||||||
}
|
|
||||||
return origlen - len(buf), count, names
|
|
||||||
}
|
|
9
vendor/golang.org/x/sys/unix/endian_big.go
generated
vendored
9
vendor/golang.org/x/sys/unix/endian_big.go
generated
vendored
@ -1,9 +0,0 @@
|
|||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
//
|
|
||||||
// +build ppc64 s390x mips mips64
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const isBigEndian = true
|
|
9
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
9
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
@ -1,9 +0,0 @@
|
|||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
//
|
|
||||||
// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const isBigEndian = false
|
|
27
vendor/golang.org/x/sys/unix/env_unix.go
generated
vendored
27
vendor/golang.org/x/sys/unix/env_unix.go
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
// Copyright 2010 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
||||||
|
|
||||||
// Unix environment variables.
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
func Getenv(key string) (value string, found bool) {
|
|
||||||
return syscall.Getenv(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Setenv(key, value string) error {
|
|
||||||
return syscall.Setenv(key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Clearenv() {
|
|
||||||
syscall.Clearenv()
|
|
||||||
}
|
|
||||||
|
|
||||||
func Environ() []string {
|
|
||||||
return syscall.Environ()
|
|
||||||
}
|
|
14
vendor/golang.org/x/sys/unix/env_unset.go
generated
vendored
14
vendor/golang.org/x/sys/unix/env_unset.go
generated
vendored
@ -1,14 +0,0 @@
|
|||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build go1.4
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
func Unsetenv(key string) error {
|
|
||||||
// This was added in Go 1.4.
|
|
||||||
return syscall.Unsetenv(key)
|
|
||||||
}
|
|
227
vendor/golang.org/x/sys/unix/errors_freebsd_386.go
generated
vendored
227
vendor/golang.org/x/sys/unix/errors_freebsd_386.go
generated
vendored
@ -1,227 +0,0 @@
|
|||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
|
||||||
// them here for backwards compatibility.
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
IFF_SMART = 0x20
|
|
||||||
IFT_1822 = 0x2
|
|
||||||
IFT_A12MPPSWITCH = 0x82
|
|
||||||
IFT_AAL2 = 0xbb
|
|
||||||
IFT_AAL5 = 0x31
|
|
||||||
IFT_ADSL = 0x5e
|
|
||||||
IFT_AFLANE8023 = 0x3b
|
|
||||||
IFT_AFLANE8025 = 0x3c
|
|
||||||
IFT_ARAP = 0x58
|
|
||||||
IFT_ARCNET = 0x23
|
|
||||||
IFT_ARCNETPLUS = 0x24
|
|
||||||
IFT_ASYNC = 0x54
|
|
||||||
IFT_ATM = 0x25
|
|
||||||
IFT_ATMDXI = 0x69
|
|
||||||
IFT_ATMFUNI = 0x6a
|
|
||||||
IFT_ATMIMA = 0x6b
|
|
||||||
IFT_ATMLOGICAL = 0x50
|
|
||||||
IFT_ATMRADIO = 0xbd
|
|
||||||
IFT_ATMSUBINTERFACE = 0x86
|
|
||||||
IFT_ATMVCIENDPT = 0xc2
|
|
||||||
IFT_ATMVIRTUAL = 0x95
|
|
||||||
IFT_BGPPOLICYACCOUNTING = 0xa2
|
|
||||||
IFT_BSC = 0x53
|
|
||||||
IFT_CCTEMUL = 0x3d
|
|
||||||
IFT_CEPT = 0x13
|
|
||||||
IFT_CES = 0x85
|
|
||||||
IFT_CHANNEL = 0x46
|
|
||||||
IFT_CNR = 0x55
|
|
||||||
IFT_COFFEE = 0x84
|
|
||||||
IFT_COMPOSITELINK = 0x9b
|
|
||||||
IFT_DCN = 0x8d
|
|
||||||
IFT_DIGITALPOWERLINE = 0x8a
|
|
||||||
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
|
|
||||||
IFT_DLSW = 0x4a
|
|
||||||
IFT_DOCSCABLEDOWNSTREAM = 0x80
|
|
||||||
IFT_DOCSCABLEMACLAYER = 0x7f
|
|
||||||
IFT_DOCSCABLEUPSTREAM = 0x81
|
|
||||||
IFT_DS0 = 0x51
|
|
||||||
IFT_DS0BUNDLE = 0x52
|
|
||||||
IFT_DS1FDL = 0xaa
|
|
||||||
IFT_DS3 = 0x1e
|
|
||||||
IFT_DTM = 0x8c
|
|
||||||
IFT_DVBASILN = 0xac
|
|
||||||
IFT_DVBASIOUT = 0xad
|
|
||||||
IFT_DVBRCCDOWNSTREAM = 0x93
|
|
||||||
IFT_DVBRCCMACLAYER = 0x92
|
|
||||||
IFT_DVBRCCUPSTREAM = 0x94
|
|
||||||
IFT_ENC = 0xf4
|
|
||||||
IFT_EON = 0x19
|
|
||||||
IFT_EPLRS = 0x57
|
|
||||||
IFT_ESCON = 0x49
|
|
||||||
IFT_ETHER = 0x6
|
|
||||||
IFT_FAITH = 0xf2
|
|
||||||
IFT_FAST = 0x7d
|
|
||||||
IFT_FASTETHER = 0x3e
|
|
||||||
IFT_FASTETHERFX = 0x45
|
|
||||||
IFT_FDDI = 0xf
|
|
||||||
IFT_FIBRECHANNEL = 0x38
|
|
||||||
IFT_FRAMERELAYINTERCONNECT = 0x3a
|
|
||||||
IFT_FRAMERELAYMPI = 0x5c
|
|
||||||
IFT_FRDLCIENDPT = 0xc1
|
|
||||||
IFT_FRELAY = 0x20
|
|
||||||
IFT_FRELAYDCE = 0x2c
|
|
||||||
IFT_FRF16MFRBUNDLE = 0xa3
|
|
||||||
IFT_FRFORWARD = 0x9e
|
|
||||||
IFT_G703AT2MB = 0x43
|
|
||||||
IFT_G703AT64K = 0x42
|
|
||||||
IFT_GIF = 0xf0
|
|
||||||
IFT_GIGABITETHERNET = 0x75
|
|
||||||
IFT_GR303IDT = 0xb2
|
|
||||||
IFT_GR303RDT = 0xb1
|
|
||||||
IFT_H323GATEKEEPER = 0xa4
|
|
||||||
IFT_H323PROXY = 0xa5
|
|
||||||
IFT_HDH1822 = 0x3
|
|
||||||
IFT_HDLC = 0x76
|
|
||||||
IFT_HDSL2 = 0xa8
|
|
||||||
IFT_HIPERLAN2 = 0xb7
|
|
||||||
IFT_HIPPI = 0x2f
|
|
||||||
IFT_HIPPIINTERFACE = 0x39
|
|
||||||
IFT_HOSTPAD = 0x5a
|
|
||||||
IFT_HSSI = 0x2e
|
|
||||||
IFT_HY = 0xe
|
|
||||||
IFT_IBM370PARCHAN = 0x48
|
|
||||||
IFT_IDSL = 0x9a
|
|
||||||
IFT_IEEE80211 = 0x47
|
|
||||||
IFT_IEEE80212 = 0x37
|
|
||||||
IFT_IEEE8023ADLAG = 0xa1
|
|
||||||
IFT_IFGSN = 0x91
|
|
||||||
IFT_IMT = 0xbe
|
|
||||||
IFT_INTERLEAVE = 0x7c
|
|
||||||
IFT_IP = 0x7e
|
|
||||||
IFT_IPFORWARD = 0x8e
|
|
||||||
IFT_IPOVERATM = 0x72
|
|
||||||
IFT_IPOVERCDLC = 0x6d
|
|
||||||
IFT_IPOVERCLAW = 0x6e
|
|
||||||
IFT_IPSWITCH = 0x4e
|
|
||||||
IFT_IPXIP = 0xf9
|
|
||||||
IFT_ISDN = 0x3f
|
|
||||||
IFT_ISDNBASIC = 0x14
|
|
||||||
IFT_ISDNPRIMARY = 0x15
|
|
||||||
IFT_ISDNS = 0x4b
|
|
||||||
IFT_ISDNU = 0x4c
|
|
||||||
IFT_ISO88022LLC = 0x29
|
|
||||||
IFT_ISO88023 = 0x7
|
|
||||||
IFT_ISO88024 = 0x8
|
|
||||||
IFT_ISO88025 = 0x9
|
|
||||||
IFT_ISO88025CRFPINT = 0x62
|
|
||||||
IFT_ISO88025DTR = 0x56
|
|
||||||
IFT_ISO88025FIBER = 0x73
|
|
||||||
IFT_ISO88026 = 0xa
|
|
||||||
IFT_ISUP = 0xb3
|
|
||||||
IFT_L3IPXVLAN = 0x89
|
|
||||||
IFT_LAPB = 0x10
|
|
||||||
IFT_LAPD = 0x4d
|
|
||||||
IFT_LAPF = 0x77
|
|
||||||
IFT_LOCALTALK = 0x2a
|
|
||||||
IFT_LOOP = 0x18
|
|
||||||
IFT_MEDIAMAILOVERIP = 0x8b
|
|
||||||
IFT_MFSIGLINK = 0xa7
|
|
||||||
IFT_MIOX25 = 0x26
|
|
||||||
IFT_MODEM = 0x30
|
|
||||||
IFT_MPC = 0x71
|
|
||||||
IFT_MPLS = 0xa6
|
|
||||||
IFT_MPLSTUNNEL = 0x96
|
|
||||||
IFT_MSDSL = 0x8f
|
|
||||||
IFT_MVL = 0xbf
|
|
||||||
IFT_MYRINET = 0x63
|
|
||||||
IFT_NFAS = 0xaf
|
|
||||||
IFT_NSIP = 0x1b
|
|
||||||
IFT_OPTICALCHANNEL = 0xc3
|
|
||||||
IFT_OPTICALTRANSPORT = 0xc4
|
|
||||||
IFT_OTHER = 0x1
|
|
||||||
IFT_P10 = 0xc
|
|
||||||
IFT_P80 = 0xd
|
|
||||||
IFT_PARA = 0x22
|
|
||||||
IFT_PFLOG = 0xf6
|
|
||||||
IFT_PFSYNC = 0xf7
|
|
||||||
IFT_PLC = 0xae
|
|
||||||
IFT_POS = 0xab
|
|
||||||
IFT_PPPMULTILINKBUNDLE = 0x6c
|
|
||||||
IFT_PROPBWAP2MP = 0xb8
|
|
||||||
IFT_PROPCNLS = 0x59
|
|
||||||
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
|
|
||||||
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
|
|
||||||
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
|
|
||||||
IFT_PROPMUX = 0x36
|
|
||||||
IFT_PROPWIRELESSP2P = 0x9d
|
|
||||||
IFT_PTPSERIAL = 0x16
|
|
||||||
IFT_PVC = 0xf1
|
|
||||||
IFT_QLLC = 0x44
|
|
||||||
IFT_RADIOMAC = 0xbc
|
|
||||||
IFT_RADSL = 0x5f
|
|
||||||
IFT_REACHDSL = 0xc0
|
|
||||||
IFT_RFC1483 = 0x9f
|
|
||||||
IFT_RS232 = 0x21
|
|
||||||
IFT_RSRB = 0x4f
|
|
||||||
IFT_SDLC = 0x11
|
|
||||||
IFT_SDSL = 0x60
|
|
||||||
IFT_SHDSL = 0xa9
|
|
||||||
IFT_SIP = 0x1f
|
|
||||||
IFT_SLIP = 0x1c
|
|
||||||
IFT_SMDSDXI = 0x2b
|
|
||||||
IFT_SMDSICIP = 0x34
|
|
||||||
IFT_SONET = 0x27
|
|
||||||
IFT_SONETOVERHEADCHANNEL = 0xb9
|
|
||||||
IFT_SONETPATH = 0x32
|
|
||||||
IFT_SONETVT = 0x33
|
|
||||||
IFT_SRP = 0x97
|
|
||||||
IFT_SS7SIGLINK = 0x9c
|
|
||||||
IFT_STACKTOSTACK = 0x6f
|
|
||||||
IFT_STARLAN = 0xb
|
|
||||||
IFT_STF = 0xd7
|
|
||||||
IFT_T1 = 0x12
|
|
||||||
IFT_TDLC = 0x74
|
|
||||||
IFT_TERMPAD = 0x5b
|
|
||||||
IFT_TR008 = 0xb0
|
|
||||||
IFT_TRANSPHDLC = 0x7b
|
|
||||||
IFT_TUNNEL = 0x83
|
|
||||||
IFT_ULTRA = 0x1d
|
|
||||||
IFT_USB = 0xa0
|
|
||||||
IFT_V11 = 0x40
|
|
||||||
IFT_V35 = 0x2d
|
|
||||||
IFT_V36 = 0x41
|
|
||||||
IFT_V37 = 0x78
|
|
||||||
IFT_VDSL = 0x61
|
|
||||||
IFT_VIRTUALIPADDRESS = 0x70
|
|
||||||
IFT_VOICEEM = 0x64
|
|
||||||
IFT_VOICEENCAP = 0x67
|
|
||||||
IFT_VOICEFXO = 0x65
|
|
||||||
IFT_VOICEFXS = 0x66
|
|
||||||
IFT_VOICEOVERATM = 0x98
|
|
||||||
IFT_VOICEOVERFRAMERELAY = 0x99
|
|
||||||
IFT_VOICEOVERIP = 0x68
|
|
||||||
IFT_X213 = 0x5d
|
|
||||||
IFT_X25 = 0x5
|
|
||||||
IFT_X25DDN = 0x4
|
|
||||||
IFT_X25HUNTGROUP = 0x7a
|
|
||||||
IFT_X25MLP = 0x79
|
|
||||||
IFT_X25PLE = 0x28
|
|
||||||
IFT_XETHER = 0x1a
|
|
||||||
IPPROTO_MAXID = 0x34
|
|
||||||
IPV6_FAITH = 0x1d
|
|
||||||
IP_FAITH = 0x16
|
|
||||||
MAP_NORESERVE = 0x40
|
|
||||||
MAP_RENAME = 0x20
|
|
||||||
NET_RT_MAXID = 0x6
|
|
||||||
RTF_PRCLONING = 0x10000
|
|
||||||
RTM_OLDADD = 0x9
|
|
||||||
RTM_OLDDEL = 0xa
|
|
||||||
SIOCADDRT = 0x8030720a
|
|
||||||
SIOCALIFADDR = 0x8118691b
|
|
||||||
SIOCDELRT = 0x8030720b
|
|
||||||
SIOCDLIFADDR = 0x8118691d
|
|
||||||
SIOCGLIFADDR = 0xc118691c
|
|
||||||
SIOCGLIFPHYADDR = 0xc118694b
|
|
||||||
SIOCSLIFPHYADDR = 0x8118694a
|
|
||||||
)
|
|
227
vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
generated
vendored
227
vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
generated
vendored
@ -1,227 +0,0 @@
|
|||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
|
||||||
// them here for backwards compatibility.
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
IFF_SMART = 0x20
|
|
||||||
IFT_1822 = 0x2
|
|
||||||
IFT_A12MPPSWITCH = 0x82
|
|
||||||
IFT_AAL2 = 0xbb
|
|
||||||
IFT_AAL5 = 0x31
|
|
||||||
IFT_ADSL = 0x5e
|
|
||||||
IFT_AFLANE8023 = 0x3b
|
|
||||||
IFT_AFLANE8025 = 0x3c
|
|
||||||
IFT_ARAP = 0x58
|
|
||||||
IFT_ARCNET = 0x23
|
|
||||||
IFT_ARCNETPLUS = 0x24
|
|
||||||
IFT_ASYNC = 0x54
|
|
||||||
IFT_ATM = 0x25
|
|
||||||
IFT_ATMDXI = 0x69
|
|
||||||
IFT_ATMFUNI = 0x6a
|
|
||||||
IFT_ATMIMA = 0x6b
|
|
||||||
IFT_ATMLOGICAL = 0x50
|
|
||||||
IFT_ATMRADIO = 0xbd
|
|
||||||
IFT_ATMSUBINTERFACE = 0x86
|
|
||||||
IFT_ATMVCIENDPT = 0xc2
|
|
||||||
IFT_ATMVIRTUAL = 0x95
|
|
||||||
IFT_BGPPOLICYACCOUNTING = 0xa2
|
|
||||||
IFT_BSC = 0x53
|
|
||||||
IFT_CCTEMUL = 0x3d
|
|
||||||
IFT_CEPT = 0x13
|
|
||||||
IFT_CES = 0x85
|
|
||||||
IFT_CHANNEL = 0x46
|
|
||||||
IFT_CNR = 0x55
|
|
||||||
IFT_COFFEE = 0x84
|
|
||||||
IFT_COMPOSITELINK = 0x9b
|
|
||||||
IFT_DCN = 0x8d
|
|
||||||
IFT_DIGITALPOWERLINE = 0x8a
|
|
||||||
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
|
|
||||||
IFT_DLSW = 0x4a
|
|
||||||
IFT_DOCSCABLEDOWNSTREAM = 0x80
|
|
||||||
IFT_DOCSCABLEMACLAYER = 0x7f
|
|
||||||
IFT_DOCSCABLEUPSTREAM = 0x81
|
|
||||||
IFT_DS0 = 0x51
|
|
||||||
IFT_DS0BUNDLE = 0x52
|
|
||||||
IFT_DS1FDL = 0xaa
|
|
||||||
IFT_DS3 = 0x1e
|
|
||||||
IFT_DTM = 0x8c
|
|
||||||
IFT_DVBASILN = 0xac
|
|
||||||
IFT_DVBASIOUT = 0xad
|
|
||||||
IFT_DVBRCCDOWNSTREAM = 0x93
|
|
||||||
IFT_DVBRCCMACLAYER = 0x92
|
|
||||||
IFT_DVBRCCUPSTREAM = 0x94
|
|
||||||
IFT_ENC = 0xf4
|
|
||||||
IFT_EON = 0x19
|
|
||||||
IFT_EPLRS = 0x57
|
|
||||||
IFT_ESCON = 0x49
|
|
||||||
IFT_ETHER = 0x6
|
|
||||||
IFT_FAITH = 0xf2
|
|
||||||
IFT_FAST = 0x7d
|
|
||||||
IFT_FASTETHER = 0x3e
|
|
||||||
IFT_FASTETHERFX = 0x45
|
|
||||||
IFT_FDDI = 0xf
|
|
||||||
IFT_FIBRECHANNEL = 0x38
|
|
||||||
IFT_FRAMERELAYINTERCONNECT = 0x3a
|
|
||||||
IFT_FRAMERELAYMPI = 0x5c
|
|
||||||
IFT_FRDLCIENDPT = 0xc1
|
|
||||||
IFT_FRELAY = 0x20
|
|
||||||
IFT_FRELAYDCE = 0x2c
|
|
||||||
IFT_FRF16MFRBUNDLE = 0xa3
|
|
||||||
IFT_FRFORWARD = 0x9e
|
|
||||||
IFT_G703AT2MB = 0x43
|
|
||||||
IFT_G703AT64K = 0x42
|
|
||||||
IFT_GIF = 0xf0
|
|
||||||
IFT_GIGABITETHERNET = 0x75
|
|
||||||
IFT_GR303IDT = 0xb2
|
|
||||||
IFT_GR303RDT = 0xb1
|
|
||||||
IFT_H323GATEKEEPER = 0xa4
|
|
||||||
IFT_H323PROXY = 0xa5
|
|
||||||
IFT_HDH1822 = 0x3
|
|
||||||
IFT_HDLC = 0x76
|
|
||||||
IFT_HDSL2 = 0xa8
|
|
||||||
IFT_HIPERLAN2 = 0xb7
|
|
||||||
IFT_HIPPI = 0x2f
|
|
||||||
IFT_HIPPIINTERFACE = 0x39
|
|
||||||
IFT_HOSTPAD = 0x5a
|
|
||||||
IFT_HSSI = 0x2e
|
|
||||||
IFT_HY = 0xe
|
|
||||||
IFT_IBM370PARCHAN = 0x48
|
|
||||||
IFT_IDSL = 0x9a
|
|
||||||
IFT_IEEE80211 = 0x47
|
|
||||||
IFT_IEEE80212 = 0x37
|
|
||||||
IFT_IEEE8023ADLAG = 0xa1
|
|
||||||
IFT_IFGSN = 0x91
|
|
||||||
IFT_IMT = 0xbe
|
|
||||||
IFT_INTERLEAVE = 0x7c
|
|
||||||
IFT_IP = 0x7e
|
|
||||||
IFT_IPFORWARD = 0x8e
|
|
||||||
IFT_IPOVERATM = 0x72
|
|
||||||
IFT_IPOVERCDLC = 0x6d
|
|
||||||
IFT_IPOVERCLAW = 0x6e
|
|
||||||
IFT_IPSWITCH = 0x4e
|
|
||||||
IFT_IPXIP = 0xf9
|
|
||||||
IFT_ISDN = 0x3f
|
|
||||||
IFT_ISDNBASIC = 0x14
|
|
||||||
IFT_ISDNPRIMARY = 0x15
|
|
||||||
IFT_ISDNS = 0x4b
|
|
||||||
IFT_ISDNU = 0x4c
|
|
||||||
IFT_ISO88022LLC = 0x29
|
|
||||||
IFT_ISO88023 = 0x7
|
|
||||||
IFT_ISO88024 = 0x8
|
|
||||||
IFT_ISO88025 = 0x9
|
|
||||||
IFT_ISO88025CRFPINT = 0x62
|
|
||||||
IFT_ISO88025DTR = 0x56
|
|
||||||
IFT_ISO88025FIBER = 0x73
|
|
||||||
IFT_ISO88026 = 0xa
|
|
||||||
IFT_ISUP = 0xb3
|
|
||||||
IFT_L3IPXVLAN = 0x89
|
|
||||||
IFT_LAPB = 0x10
|
|
||||||
IFT_LAPD = 0x4d
|
|
||||||
IFT_LAPF = 0x77
|
|
||||||
IFT_LOCALTALK = 0x2a
|
|
||||||
IFT_LOOP = 0x18
|
|
||||||
IFT_MEDIAMAILOVERIP = 0x8b
|
|
||||||
IFT_MFSIGLINK = 0xa7
|
|
||||||
IFT_MIOX25 = 0x26
|
|
||||||
IFT_MODEM = 0x30
|
|
||||||
IFT_MPC = 0x71
|
|
||||||
IFT_MPLS = 0xa6
|
|
||||||
IFT_MPLSTUNNEL = 0x96
|
|
||||||
IFT_MSDSL = 0x8f
|
|
||||||
IFT_MVL = 0xbf
|
|
||||||
IFT_MYRINET = 0x63
|
|
||||||
IFT_NFAS = 0xaf
|
|
||||||
IFT_NSIP = 0x1b
|
|
||||||
IFT_OPTICALCHANNEL = 0xc3
|
|
||||||
IFT_OPTICALTRANSPORT = 0xc4
|
|
||||||
IFT_OTHER = 0x1
|
|
||||||
IFT_P10 = 0xc
|
|
||||||
IFT_P80 = 0xd
|
|
||||||
IFT_PARA = 0x22
|
|
||||||
IFT_PFLOG = 0xf6
|
|
||||||
IFT_PFSYNC = 0xf7
|
|
||||||
IFT_PLC = 0xae
|
|
||||||
IFT_POS = 0xab
|
|
||||||
IFT_PPPMULTILINKBUNDLE = 0x6c
|
|
||||||
IFT_PROPBWAP2MP = 0xb8
|
|
||||||
IFT_PROPCNLS = 0x59
|
|
||||||
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
|
|
||||||
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
|
|
||||||
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
|
|
||||||
IFT_PROPMUX = 0x36
|
|
||||||
IFT_PROPWIRELESSP2P = 0x9d
|
|
||||||
IFT_PTPSERIAL = 0x16
|
|
||||||
IFT_PVC = 0xf1
|
|
||||||
IFT_QLLC = 0x44
|
|
||||||
IFT_RADIOMAC = 0xbc
|
|
||||||
IFT_RADSL = 0x5f
|
|
||||||
IFT_REACHDSL = 0xc0
|
|
||||||
IFT_RFC1483 = 0x9f
|
|
||||||
IFT_RS232 = 0x21
|
|
||||||
IFT_RSRB = 0x4f
|
|
||||||
IFT_SDLC = 0x11
|
|
||||||
IFT_SDSL = 0x60
|
|
||||||
IFT_SHDSL = 0xa9
|
|
||||||
IFT_SIP = 0x1f
|
|
||||||
IFT_SLIP = 0x1c
|
|
||||||
IFT_SMDSDXI = 0x2b
|
|
||||||
IFT_SMDSICIP = 0x34
|
|
||||||
IFT_SONET = 0x27
|
|
||||||
IFT_SONETOVERHEADCHANNEL = 0xb9
|
|
||||||
IFT_SONETPATH = 0x32
|
|
||||||
IFT_SONETVT = 0x33
|
|
||||||
IFT_SRP = 0x97
|
|
||||||
IFT_SS7SIGLINK = 0x9c
|
|
||||||
IFT_STACKTOSTACK = 0x6f
|
|
||||||
IFT_STARLAN = 0xb
|
|
||||||
IFT_STF = 0xd7
|
|
||||||
IFT_T1 = 0x12
|
|
||||||
IFT_TDLC = 0x74
|
|
||||||
IFT_TERMPAD = 0x5b
|
|
||||||
IFT_TR008 = 0xb0
|
|
||||||
IFT_TRANSPHDLC = 0x7b
|
|
||||||
IFT_TUNNEL = 0x83
|
|
||||||
IFT_ULTRA = 0x1d
|
|
||||||
IFT_USB = 0xa0
|
|
||||||
IFT_V11 = 0x40
|
|
||||||
IFT_V35 = 0x2d
|
|
||||||
IFT_V36 = 0x41
|
|
||||||
IFT_V37 = 0x78
|
|
||||||
IFT_VDSL = 0x61
|
|
||||||
IFT_VIRTUALIPADDRESS = 0x70
|
|
||||||
IFT_VOICEEM = 0x64
|
|
||||||
IFT_VOICEENCAP = 0x67
|
|
||||||
IFT_VOICEFXO = 0x65
|
|
||||||
IFT_VOICEFXS = 0x66
|
|
||||||
IFT_VOICEOVERATM = 0x98
|
|
||||||
IFT_VOICEOVERFRAMERELAY = 0x99
|
|
||||||
IFT_VOICEOVERIP = 0x68
|
|
||||||
IFT_X213 = 0x5d
|
|
||||||
IFT_X25 = 0x5
|
|
||||||
IFT_X25DDN = 0x4
|
|
||||||
IFT_X25HUNTGROUP = 0x7a
|
|
||||||
IFT_X25MLP = 0x79
|
|
||||||
IFT_X25PLE = 0x28
|
|
||||||
IFT_XETHER = 0x1a
|
|
||||||
IPPROTO_MAXID = 0x34
|
|
||||||
IPV6_FAITH = 0x1d
|
|
||||||
IP_FAITH = 0x16
|
|
||||||
MAP_NORESERVE = 0x40
|
|
||||||
MAP_RENAME = 0x20
|
|
||||||
NET_RT_MAXID = 0x6
|
|
||||||
RTF_PRCLONING = 0x10000
|
|
||||||
RTM_OLDADD = 0x9
|
|
||||||
RTM_OLDDEL = 0xa
|
|
||||||
SIOCADDRT = 0x8040720a
|
|
||||||
SIOCALIFADDR = 0x8118691b
|
|
||||||
SIOCDELRT = 0x8040720b
|
|
||||||
SIOCDLIFADDR = 0x8118691d
|
|
||||||
SIOCGLIFADDR = 0xc118691c
|
|
||||||
SIOCGLIFPHYADDR = 0xc118694b
|
|
||||||
SIOCSLIFPHYADDR = 0x8118694a
|
|
||||||
)
|
|
27
vendor/golang.org/x/sys/unix/file_unix.go
generated
vendored
27
vendor/golang.org/x/sys/unix/file_unix.go
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FIXME: unexported function from os
|
|
||||||
// syscallMode returns the syscall-specific mode bits from Go's portable mode bits.
|
|
||||||
func syscallMode(i os.FileMode) (o uint32) {
|
|
||||||
o |= uint32(i.Perm())
|
|
||||||
if i&os.ModeSetuid != 0 {
|
|
||||||
o |= syscall.S_ISUID
|
|
||||||
}
|
|
||||||
if i&os.ModeSetgid != 0 {
|
|
||||||
o |= syscall.S_ISGID
|
|
||||||
}
|
|
||||||
if i&os.ModeSticky != 0 {
|
|
||||||
o |= syscall.S_ISVTX
|
|
||||||
}
|
|
||||||
// No mapping for Go's ModeTemporary (plan9 only).
|
|
||||||
return
|
|
||||||
}
|
|
22
vendor/golang.org/x/sys/unix/flock.go
generated
vendored
22
vendor/golang.org/x/sys/unix/flock.go
generated
vendored
@ -1,22 +0,0 @@
|
|||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "unsafe"
|
|
||||||
|
|
||||||
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
|
||||||
// systems by flock_linux_32bit.go to be SYS_FCNTL64.
|
|
||||||
var fcntl64Syscall uintptr = SYS_FCNTL
|
|
||||||
|
|
||||||
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
|
||||||
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
|
||||||
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
|
||||||
if errno == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return errno
|
|
||||||
}
|
|
13
vendor/golang.org/x/sys/unix/flock_linux_32bit.go
generated
vendored
13
vendor/golang.org/x/sys/unix/flock_linux_32bit.go
generated
vendored
@ -1,13 +0,0 @@
|
|||||||
// +build linux,386 linux,arm linux,mips linux,mipsle
|
|
||||||
|
|
||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
// On 32-bit Linux systems, the fcntl syscall that matches Go's
|
|
||||||
// Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
|
|
||||||
fcntl64Syscall = SYS_FCNTL64
|
|
||||||
}
|
|
46
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
46
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
@ -1,46 +0,0 @@
|
|||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build gccgo
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
// We can't use the gc-syntax .s files for gccgo. On the plus side
|
|
||||||
// much of the functionality can be written directly in Go.
|
|
||||||
|
|
||||||
//extern gccgoRealSyscall
|
|
||||||
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
|
|
||||||
|
|
||||||
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
|
||||||
syscall.Entersyscall()
|
|
||||||
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
|
||||||
syscall.Exitsyscall()
|
|
||||||
return r, 0, syscall.Errno(errno)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
|
||||||
syscall.Entersyscall()
|
|
||||||
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
|
|
||||||
syscall.Exitsyscall()
|
|
||||||
return r, 0, syscall.Errno(errno)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
|
||||||
syscall.Entersyscall()
|
|
||||||
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
|
|
||||||
syscall.Exitsyscall()
|
|
||||||
return r, 0, syscall.Errno(errno)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
|
||||||
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
|
||||||
return r, 0, syscall.Errno(errno)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
|
||||||
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
|
|
||||||
return r, 0, syscall.Errno(errno)
|
|
||||||
}
|
|
41
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
41
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
@ -1,41 +0,0 @@
|
|||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build gccgo
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define _STRINGIFY2_(x) #x
|
|
||||||
#define _STRINGIFY_(x) _STRINGIFY2_(x)
|
|
||||||
#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
|
|
||||||
|
|
||||||
// Call syscall from C code because the gccgo support for calling from
|
|
||||||
// Go to C does not support varargs functions.
|
|
||||||
|
|
||||||
struct ret {
|
|
||||||
uintptr_t r;
|
|
||||||
uintptr_t err;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ret
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
struct ret r;
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
||||||
r.err = errno;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define the use function in C so that it is not inlined.
|
|
||||||
|
|
||||||
extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
|
|
||||||
|
|
||||||
void
|
|
||||||
use(void *p __attribute__ ((unused)))
|
|
||||||
{
|
|
||||||
}
|
|
20
vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
generated
vendored
20
vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
generated
vendored
@ -1,20 +0,0 @@
|
|||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build gccgo,linux,amd64
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
//extern gettimeofday
|
|
||||||
func realGettimeofday(*Timeval, *byte) int32
|
|
||||||
|
|
||||||
func gettimeofday(tv *Timeval) (err syscall.Errno) {
|
|
||||||
r := realGettimeofday(tv, nil)
|
|
||||||
if r < 0 {
|
|
||||||
return syscall.GetErrno()
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
20
vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go
generated
vendored
20
vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go
generated
vendored
@ -1,20 +0,0 @@
|
|||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build gccgo,linux,sparc64
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
//extern sysconf
|
|
||||||
func realSysconf(name int) int64
|
|
||||||
|
|
||||||
func sysconf(name int) (n int64, err syscall.Errno) {
|
|
||||||
r := realSysconf(name)
|
|
||||||
if r < 0 {
|
|
||||||
return 0, syscall.GetErrno()
|
|
||||||
}
|
|
||||||
return r, 0
|
|
||||||
}
|
|
179
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
179
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
@ -1,179 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
# This script runs or (given -n) prints suggested commands to generate files for
|
|
||||||
# the Architecture/OS specified by the GOARCH and GOOS environment variables.
|
|
||||||
# See README.md for more information about how the build system works.
|
|
||||||
|
|
||||||
GOOSARCH="${GOOS}_${GOARCH}"
|
|
||||||
|
|
||||||
# defaults
|
|
||||||
mksyscall="./mksyscall.pl"
|
|
||||||
mkerrors="./mkerrors.sh"
|
|
||||||
zerrors="zerrors_$GOOSARCH.go"
|
|
||||||
mksysctl=""
|
|
||||||
zsysctl="zsysctl_$GOOSARCH.go"
|
|
||||||
mksysnum=
|
|
||||||
mktypes=
|
|
||||||
run="sh"
|
|
||||||
cmd=""
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
-syscalls)
|
|
||||||
for i in zsyscall*go
|
|
||||||
do
|
|
||||||
# Run the command line that appears in the first line
|
|
||||||
# of the generated file to regenerate it.
|
|
||||||
sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
|
|
||||||
rm _$i
|
|
||||||
done
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-n)
|
|
||||||
run="cat"
|
|
||||||
cmd="echo"
|
|
||||||
shift
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$#" in
|
|
||||||
0)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo 'usage: mkall.sh [-n]' 1>&2
|
|
||||||
exit 2
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
|
|
||||||
# Use then new build system
|
|
||||||
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
|
||||||
$cmd docker build --tag generate:$GOOS $GOOS
|
|
||||||
$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
GOOSARCH_in=syscall_$GOOSARCH.go
|
|
||||||
case "$GOOSARCH" in
|
|
||||||
_* | *_ | _)
|
|
||||||
echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
darwin_386)
|
|
||||||
mkerrors="$mkerrors -m32"
|
|
||||||
mksyscall="./mksyscall.pl -l32"
|
|
||||||
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
darwin_amd64)
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
darwin_arm)
|
|
||||||
mkerrors="$mkerrors"
|
|
||||||
mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
darwin_arm64)
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
dragonfly_386)
|
|
||||||
mkerrors="$mkerrors -m32"
|
|
||||||
mksyscall="./mksyscall.pl -l32 -dragonfly"
|
|
||||||
mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
dragonfly_amd64)
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksyscall="./mksyscall.pl -dragonfly"
|
|
||||||
mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
freebsd_386)
|
|
||||||
mkerrors="$mkerrors -m32"
|
|
||||||
mksyscall="./mksyscall.pl -l32"
|
|
||||||
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
freebsd_amd64)
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
freebsd_arm)
|
|
||||||
mkerrors="$mkerrors"
|
|
||||||
mksyscall="./mksyscall.pl -l32 -arm"
|
|
||||||
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
|
||||||
# Let the type of C char be signed for making the bare syscall
|
|
||||||
# API consistent across over platforms.
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
|
||||||
;;
|
|
||||||
linux_sparc64)
|
|
||||||
GOOSARCH_in=syscall_linux_sparc64.go
|
|
||||||
unistd_h=/usr/include/sparc64-linux-gnu/asm/unistd.h
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksysnum="./mksysnum_linux.pl $unistd_h"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
netbsd_386)
|
|
||||||
mkerrors="$mkerrors -m32"
|
|
||||||
mksyscall="./mksyscall.pl -l32 -netbsd"
|
|
||||||
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
netbsd_amd64)
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksyscall="./mksyscall.pl -netbsd"
|
|
||||||
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
openbsd_386)
|
|
||||||
mkerrors="$mkerrors -m32"
|
|
||||||
mksyscall="./mksyscall.pl -l32 -openbsd"
|
|
||||||
mksysctl="./mksysctl_openbsd.pl"
|
|
||||||
zsysctl="zsysctl_openbsd.go"
|
|
||||||
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
openbsd_amd64)
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksyscall="./mksyscall.pl -openbsd"
|
|
||||||
mksysctl="./mksysctl_openbsd.pl"
|
|
||||||
zsysctl="zsysctl_openbsd.go"
|
|
||||||
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
solaris_amd64)
|
|
||||||
mksyscall="./mksyscall_solaris.pl"
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksysnum=
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
(
|
|
||||||
if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
|
|
||||||
case "$GOOS" in
|
|
||||||
*)
|
|
||||||
syscall_goos="syscall_$GOOS.go"
|
|
||||||
case "$GOOS" in
|
|
||||||
darwin | dragonfly | freebsd | netbsd | openbsd)
|
|
||||||
syscall_goos="syscall_bsd.go $syscall_goos"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if [ -n "$mksyscall" ]; then echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
|
|
||||||
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
|
|
||||||
if [ -n "$mktypes" ]; then
|
|
||||||
echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go";
|
|
||||||
fi
|
|
||||||
) | $run
|
|
558
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
558
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
@ -1,558 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
# Generate Go code listing errors and other #defined constant
|
|
||||||
# values (ENAMETOOLONG etc.), by asking the preprocessor
|
|
||||||
# about the definitions.
|
|
||||||
|
|
||||||
unset LANG
|
|
||||||
export LC_ALL=C
|
|
||||||
export LC_CTYPE=C
|
|
||||||
|
|
||||||
if test -z "$GOARCH" -o -z "$GOOS"; then
|
|
||||||
echo 1>&2 "GOARCH or GOOS not defined in environment"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check that we are using the new build system if we should
|
|
||||||
if [[ "$GOOS" -eq "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
|
|
||||||
if [[ "$GOLANG_SYS_BUILD" -ne "docker" ]]; then
|
|
||||||
echo 1>&2 "In the new build system, mkerrors should not be called directly."
|
|
||||||
echo 1>&2 "See README.md"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
CC=${CC:-cc}
|
|
||||||
|
|
||||||
if [[ "$GOOS" -eq "solaris" ]]; then
|
|
||||||
# Assumes GNU versions of utilities in PATH.
|
|
||||||
export PATH=/usr/gnu/bin:$PATH
|
|
||||||
fi
|
|
||||||
|
|
||||||
uname=$(uname)
|
|
||||||
|
|
||||||
includes_Darwin='
|
|
||||||
#define _DARWIN_C_SOURCE
|
|
||||||
#define KERNEL
|
|
||||||
#define _DARWIN_USE_64_BIT_INODE
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/ptrace.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/sockio.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_types.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <termios.h>
|
|
||||||
'
|
|
||||||
|
|
||||||
includes_DragonFly='
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/sockio.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_types.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <net/ip_mroute/ip_mroute.h>
|
|
||||||
'
|
|
||||||
|
|
||||||
includes_FreeBSD='
|
|
||||||
#include <sys/capability.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/sockio.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_types.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <netinet/ip_mroute.h>
|
|
||||||
#include <sys/extattr.h>
|
|
||||||
|
|
||||||
#if __FreeBSD__ >= 10
|
|
||||||
#define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10
|
|
||||||
#undef SIOCAIFADDR
|
|
||||||
#define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data
|
|
||||||
#undef SIOCSIFPHYADDR
|
|
||||||
#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data
|
|
||||||
#endif
|
|
||||||
'
|
|
||||||
|
|
||||||
includes_Linux='
|
|
||||||
#define _LARGEFILE_SOURCE
|
|
||||||
#define _LARGEFILE64_SOURCE
|
|
||||||
#ifndef __LP64__
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
|
||||||
#endif
|
|
||||||
#define _GNU_SOURCE
|
|
||||||
|
|
||||||
// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
|
|
||||||
// these structures. We just include them copied from <bits/termios.h>.
|
|
||||||
#if defined(__powerpc__)
|
|
||||||
struct sgttyb {
|
|
||||||
char sg_ispeed;
|
|
||||||
char sg_ospeed;
|
|
||||||
char sg_erase;
|
|
||||||
char sg_kill;
|
|
||||||
short sg_flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct tchars {
|
|
||||||
char t_intrc;
|
|
||||||
char t_quitc;
|
|
||||||
char t_startc;
|
|
||||||
char t_stopc;
|
|
||||||
char t_eofc;
|
|
||||||
char t_brkc;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ltchars {
|
|
||||||
char t_suspc;
|
|
||||||
char t_dsuspc;
|
|
||||||
char t_rprntc;
|
|
||||||
char t_flushc;
|
|
||||||
char t_werasc;
|
|
||||||
char t_lnextc;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <bits/sockaddr.h>
|
|
||||||
#include <sys/epoll.h>
|
|
||||||
#include <sys/eventfd.h>
|
|
||||||
#include <sys/inotify.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/prctl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/xattr.h>
|
|
||||||
#include <linux/if.h>
|
|
||||||
#include <linux/if_alg.h>
|
|
||||||
#include <linux/if_arp.h>
|
|
||||||
#include <linux/if_ether.h>
|
|
||||||
#include <linux/if_tun.h>
|
|
||||||
#include <linux/if_packet.h>
|
|
||||||
#include <linux/if_addr.h>
|
|
||||||
#include <linux/falloc.h>
|
|
||||||
#include <linux/filter.h>
|
|
||||||
#include <linux/fs.h>
|
|
||||||
#include <linux/keyctl.h>
|
|
||||||
#include <linux/netlink.h>
|
|
||||||
#include <linux/perf_event.h>
|
|
||||||
#include <linux/random.h>
|
|
||||||
#include <linux/reboot.h>
|
|
||||||
#include <linux/rtnetlink.h>
|
|
||||||
#include <linux/ptrace.h>
|
|
||||||
#include <linux/sched.h>
|
|
||||||
#include <linux/seccomp.h>
|
|
||||||
#include <linux/sockios.h>
|
|
||||||
#include <linux/wait.h>
|
|
||||||
#include <linux/icmpv6.h>
|
|
||||||
#include <linux/serial.h>
|
|
||||||
#include <linux/can.h>
|
|
||||||
#include <linux/vm_sockets.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <asm/termbits.h>
|
|
||||||
|
|
||||||
#ifndef MSG_FASTOPEN
|
|
||||||
#define MSG_FASTOPEN 0x20000000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PTRACE_GETREGS
|
|
||||||
#define PTRACE_GETREGS 0xc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PTRACE_SETREGS
|
|
||||||
#define PTRACE_SETREGS 0xd
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SOL_NETLINK
|
|
||||||
#define SOL_NETLINK 270
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SOL_BLUETOOTH
|
|
||||||
// SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h
|
|
||||||
// but it is already in bluetooth_linux.go
|
|
||||||
#undef SOL_BLUETOOTH
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Certain constants are missing from the fs/crypto UAPI
|
|
||||||
#define FS_KEY_DESC_PREFIX "fscrypt:"
|
|
||||||
#define FS_KEY_DESC_PREFIX_SIZE 8
|
|
||||||
#define FS_MAX_KEY_SIZE 64
|
|
||||||
'
|
|
||||||
|
|
||||||
includes_NetBSD='
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/sockio.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/termios.h>
|
|
||||||
#include <sys/ttycom.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_types.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/in_systm.h>
|
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <netinet/ip_mroute.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
|
|
||||||
// Needed since <sys/param.h> refers to it...
|
|
||||||
#define schedppq 1
|
|
||||||
'
|
|
||||||
|
|
||||||
includes_OpenBSD='
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/sockio.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/termios.h>
|
|
||||||
#include <sys/ttycom.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_types.h>
|
|
||||||
#include <net/if_var.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/in_systm.h>
|
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <netinet/ip_mroute.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
#include <net/if_bridge.h>
|
|
||||||
|
|
||||||
// We keep some constants not supported in OpenBSD 5.5 and beyond for
|
|
||||||
// the promise of compatibility.
|
|
||||||
#define EMUL_ENABLED 0x1
|
|
||||||
#define EMUL_NATIVE 0x2
|
|
||||||
#define IPV6_FAITH 0x1d
|
|
||||||
#define IPV6_OPTIONS 0x1
|
|
||||||
#define IPV6_RTHDR_STRICT 0x1
|
|
||||||
#define IPV6_SOCKOPT_RESERVED1 0x3
|
|
||||||
#define SIOCGIFGENERIC 0xc020693a
|
|
||||||
#define SIOCSIFGENERIC 0x80206939
|
|
||||||
#define WALTSIG 0x4
|
|
||||||
'
|
|
||||||
|
|
||||||
includes_SunOS='
|
|
||||||
#include <limits.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/sockio.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_arp.h>
|
|
||||||
#include <net/if_types.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <netinet/ip_mroute.h>
|
|
||||||
'
|
|
||||||
|
|
||||||
|
|
||||||
includes='
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <netinet/ip6.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <time.h>
|
|
||||||
'
|
|
||||||
ccflags="$@"
|
|
||||||
|
|
||||||
# Write go tool cgo -godefs input.
|
|
||||||
(
|
|
||||||
echo package unix
|
|
||||||
echo
|
|
||||||
echo '/*'
|
|
||||||
indirect="includes_$(uname)"
|
|
||||||
echo "${!indirect} $includes"
|
|
||||||
echo '*/'
|
|
||||||
echo 'import "C"'
|
|
||||||
echo 'import "syscall"'
|
|
||||||
echo
|
|
||||||
echo 'const ('
|
|
||||||
|
|
||||||
# The gcc command line prints all the #defines
|
|
||||||
# it encounters while processing the input
|
|
||||||
echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags |
|
|
||||||
awk '
|
|
||||||
$1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
|
|
||||||
|
|
||||||
$2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next} # 386 registers
|
|
||||||
$2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next}
|
|
||||||
$2 ~ /^(SCM_SRCRT)$/ {next}
|
|
||||||
$2 ~ /^(MAP_FAILED)$/ {next}
|
|
||||||
$2 ~ /^ELF_.*$/ {next}# <asm/elf.h> contains ELF_ARCH, etc.
|
|
||||||
|
|
||||||
$2 ~ /^EXTATTR_NAMESPACE_NAMES/ ||
|
|
||||||
$2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next}
|
|
||||||
|
|
||||||
$2 !~ /^ETH_/ &&
|
|
||||||
$2 !~ /^EPROC_/ &&
|
|
||||||
$2 !~ /^EQUIV_/ &&
|
|
||||||
$2 !~ /^EXPR_/ &&
|
|
||||||
$2 ~ /^E[A-Z0-9_]+$/ ||
|
|
||||||
$2 ~ /^B[0-9_]+$/ ||
|
|
||||||
$2 == "BOTHER" ||
|
|
||||||
$2 ~ /^CI?BAUD(EX)?$/ ||
|
|
||||||
$2 == "IBSHIFT" ||
|
|
||||||
$2 ~ /^V[A-Z0-9]+$/ ||
|
|
||||||
$2 ~ /^CS[A-Z0-9]/ ||
|
|
||||||
$2 ~ /^I(SIG|CANON|CRNL|UCLC|EXTEN|MAXBEL|STRIP|UTF8)$/ ||
|
|
||||||
$2 ~ /^IGN/ ||
|
|
||||||
$2 ~ /^IX(ON|ANY|OFF)$/ ||
|
|
||||||
$2 ~ /^IN(LCR|PCK)$/ ||
|
|
||||||
$2 ~ /(^FLU?SH)|(FLU?SH$)/ ||
|
|
||||||
$2 ~ /^C(LOCAL|READ|MSPAR|RTSCTS)$/ ||
|
|
||||||
$2 == "BRKINT" ||
|
|
||||||
$2 == "HUPCL" ||
|
|
||||||
$2 == "PENDIN" ||
|
|
||||||
$2 == "TOSTOP" ||
|
|
||||||
$2 == "XCASE" ||
|
|
||||||
$2 == "ALTWERASE" ||
|
|
||||||
$2 == "NOKERNINFO" ||
|
|
||||||
$2 ~ /^PAR/ ||
|
|
||||||
$2 ~ /^SIG[^_]/ ||
|
|
||||||
$2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
|
|
||||||
$2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ ||
|
|
||||||
$2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ ||
|
|
||||||
$2 ~ /^O?XTABS$/ ||
|
|
||||||
$2 ~ /^TC[IO](ON|OFF)$/ ||
|
|
||||||
$2 ~ /^IN_/ ||
|
|
||||||
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
|
||||||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
|
|
||||||
$2 ~ /^FALLOC_/ ||
|
|
||||||
$2 == "ICMPV6_FILTER" ||
|
|
||||||
$2 == "SOMAXCONN" ||
|
|
||||||
$2 == "NAME_MAX" ||
|
|
||||||
$2 == "IFNAMSIZ" ||
|
|
||||||
$2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
|
|
||||||
$2 ~ /^SYSCTL_VERS/ ||
|
|
||||||
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
|
||||||
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
|
||||||
$2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ ||
|
|
||||||
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
|
||||||
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
|
||||||
$2 !~ "NLA_TYPE_MASK" &&
|
|
||||||
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
|
|
||||||
$2 ~ /^SIOC/ ||
|
|
||||||
$2 ~ /^TIOC/ ||
|
|
||||||
$2 ~ /^TCGET/ ||
|
|
||||||
$2 ~ /^TCSET/ ||
|
|
||||||
$2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
|
|
||||||
$2 !~ "RTF_BITS" &&
|
|
||||||
$2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
|
|
||||||
$2 ~ /^BIOC/ ||
|
|
||||||
$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
|
|
||||||
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
|
|
||||||
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
|
||||||
$2 ~ /^CLONE_[A-Z_]+/ ||
|
|
||||||
$2 !~ /^(BPF_TIMEVAL)$/ &&
|
|
||||||
$2 ~ /^(BPF|DLT)_/ ||
|
|
||||||
$2 ~ /^CLOCK_/ ||
|
|
||||||
$2 ~ /^CAN_/ ||
|
|
||||||
$2 ~ /^CAP_/ ||
|
|
||||||
$2 ~ /^ALG_/ ||
|
|
||||||
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE|IOC_(GET|SET)_ENCRYPTION)/ ||
|
|
||||||
$2 ~ /^GRND_/ ||
|
|
||||||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
|
||||||
$2 ~ /^KEYCTL_/ ||
|
|
||||||
$2 ~ /^PERF_EVENT_IOC_/ ||
|
|
||||||
$2 ~ /^SECCOMP_MODE_/ ||
|
|
||||||
$2 ~ /^SPLICE_/ ||
|
|
||||||
$2 ~ /^(VM|VMADDR)_/ ||
|
|
||||||
$2 ~ /^XATTR_(CREATE|REPLACE)/ ||
|
|
||||||
$2 !~ "WMESGLEN" &&
|
|
||||||
$2 ~ /^W[A-Z0-9]+$/ ||
|
|
||||||
$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
|
|
||||||
$2 ~ /^__WCOREFLAG$/ {next}
|
|
||||||
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
|
|
||||||
|
|
||||||
{next}
|
|
||||||
' | sort
|
|
||||||
|
|
||||||
echo ')'
|
|
||||||
) >_const.go
|
|
||||||
|
|
||||||
# Pull out the error names for later.
|
|
||||||
errors=$(
|
|
||||||
echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
|
|
||||||
awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
|
|
||||||
sort
|
|
||||||
)
|
|
||||||
|
|
||||||
# Pull out the signal names for later.
|
|
||||||
signals=$(
|
|
||||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
|
||||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
|
||||||
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
|
|
||||||
sort
|
|
||||||
)
|
|
||||||
|
|
||||||
# Again, writing regexps to a file.
|
|
||||||
echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
|
|
||||||
awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
|
||||||
sort >_error.grep
|
|
||||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
|
||||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
|
||||||
egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
|
|
||||||
sort >_signal.grep
|
|
||||||
|
|
||||||
echo '// mkerrors.sh' "$@"
|
|
||||||
echo '// Code generated by the command above; see README.md. DO NOT EDIT.'
|
|
||||||
echo
|
|
||||||
echo "// +build ${GOARCH},${GOOS}"
|
|
||||||
echo
|
|
||||||
go tool cgo -godefs -- "$@" _const.go >_error.out
|
|
||||||
cat _error.out | grep -vf _error.grep | grep -vf _signal.grep
|
|
||||||
echo
|
|
||||||
echo '// Errors'
|
|
||||||
echo 'const ('
|
|
||||||
cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= syscall.Errno(\1)/'
|
|
||||||
echo ')'
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo '// Signals'
|
|
||||||
echo 'const ('
|
|
||||||
cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= syscall.Signal(\1)/'
|
|
||||||
echo ')'
|
|
||||||
|
|
||||||
# Run C program to print error and syscall strings.
|
|
||||||
(
|
|
||||||
echo -E "
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
|
|
||||||
|
|
||||||
enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes below
|
|
||||||
|
|
||||||
int errors[] = {
|
|
||||||
"
|
|
||||||
for i in $errors
|
|
||||||
do
|
|
||||||
echo -E ' '$i,
|
|
||||||
done
|
|
||||||
|
|
||||||
echo -E "
|
|
||||||
};
|
|
||||||
|
|
||||||
int signals[] = {
|
|
||||||
"
|
|
||||||
for i in $signals
|
|
||||||
do
|
|
||||||
echo -E ' '$i,
|
|
||||||
done
|
|
||||||
|
|
||||||
# Use -E because on some systems bash builtin interprets \n itself.
|
|
||||||
echo -E '
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
|
||||||
intcmp(const void *a, const void *b)
|
|
||||||
{
|
|
||||||
return *(int*)a - *(int*)b;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
int i, e;
|
|
||||||
char buf[1024], *p;
|
|
||||||
|
|
||||||
printf("\n\n// Error table\n");
|
|
||||||
printf("var errors = [...]string {\n");
|
|
||||||
qsort(errors, nelem(errors), sizeof errors[0], intcmp);
|
|
||||||
for(i=0; i<nelem(errors); i++) {
|
|
||||||
e = errors[i];
|
|
||||||
if(i > 0 && errors[i-1] == e)
|
|
||||||
continue;
|
|
||||||
strcpy(buf, strerror(e));
|
|
||||||
// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
|
|
||||||
if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
|
|
||||||
buf[0] += a - A;
|
|
||||||
printf("\t%d: \"%s\",\n", e, buf);
|
|
||||||
}
|
|
||||||
printf("}\n\n");
|
|
||||||
|
|
||||||
printf("\n\n// Signal table\n");
|
|
||||||
printf("var signals = [...]string {\n");
|
|
||||||
qsort(signals, nelem(signals), sizeof signals[0], intcmp);
|
|
||||||
for(i=0; i<nelem(signals); i++) {
|
|
||||||
e = signals[i];
|
|
||||||
if(i > 0 && signals[i-1] == e)
|
|
||||||
continue;
|
|
||||||
strcpy(buf, strsignal(e));
|
|
||||||
// lowercase first letter: Bad -> bad, but STREAM -> STREAM.
|
|
||||||
if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
|
|
||||||
buf[0] += a - A;
|
|
||||||
// cut trailing : number.
|
|
||||||
p = strrchr(buf, ":"[0]);
|
|
||||||
if(p)
|
|
||||||
*p = '\0';
|
|
||||||
printf("\t%d: \"%s\",\n", e, buf);
|
|
||||||
}
|
|
||||||
printf("}\n\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
'
|
|
||||||
) >_errors.c
|
|
||||||
|
|
||||||
$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c _errors _const.go _error.grep _signal.grep _error.out
|
|
88
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
88
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
@ -1,88 +0,0 @@
|
|||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
// mkpost processes the output of cgo -godefs to
|
|
||||||
// modify the generated types. It is used to clean up
|
|
||||||
// the sys API in an architecture specific manner.
|
|
||||||
//
|
|
||||||
// mkpost is run after cgo -godefs; see README.md.
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"go/format"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"regexp"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Get the OS and architecture (using GOARCH_TARGET if it exists)
|
|
||||||
goos := os.Getenv("GOOS")
|
|
||||||
goarch := os.Getenv("GOARCH_TARGET")
|
|
||||||
if goarch == "" {
|
|
||||||
goarch = os.Getenv("GOARCH")
|
|
||||||
}
|
|
||||||
// Check that we are using the new build system if we should be.
|
|
||||||
if goos == "linux" && goarch != "sparc64" {
|
|
||||||
if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
|
|
||||||
os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n")
|
|
||||||
os.Stderr.WriteString("See README.md\n")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(os.Stdin)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we have empty Ptrace structs, we should delete them. Only s390x emits
|
|
||||||
// nonempty Ptrace structs.
|
|
||||||
ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)
|
|
||||||
b = ptraceRexexp.ReplaceAll(b, nil)
|
|
||||||
|
|
||||||
// Replace the control_regs union with a blank identifier for now.
|
|
||||||
controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`)
|
|
||||||
b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64"))
|
|
||||||
|
|
||||||
// Remove fields that are added by glibc
|
|
||||||
// Note that this is unstable as the identifers are private.
|
|
||||||
removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`)
|
|
||||||
b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
|
|
||||||
|
|
||||||
// We refuse to export private fields on s390x
|
|
||||||
if goarch == "s390x" && goos == "linux" {
|
|
||||||
// Remove cgo padding fields
|
|
||||||
removeFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`)
|
|
||||||
b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
|
|
||||||
|
|
||||||
// Remove padding, hidden, or unused fields
|
|
||||||
removeFieldsRegex = regexp.MustCompile(`X_\S+`)
|
|
||||||
b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the first line of warning from cgo
|
|
||||||
b = b[bytes.IndexByte(b, '\n')+1:]
|
|
||||||
// Modify the command in the header to include:
|
|
||||||
// mkpost, our own warning, and a build tag.
|
|
||||||
replacement := fmt.Sprintf(`$1 | go run mkpost.go
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build %s,%s`, goarch, goos)
|
|
||||||
cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`)
|
|
||||||
b = cgoCommandRegex.ReplaceAll(b, []byte(replacement))
|
|
||||||
|
|
||||||
// gofmt
|
|
||||||
b, err = format.Source(b)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
os.Stdout.Write(b)
|
|
||||||
}
|
|
328
vendor/golang.org/x/sys/unix/mksyscall.pl
generated
vendored
328
vendor/golang.org/x/sys/unix/mksyscall.pl
generated
vendored
@ -1,328 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
# Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
# This program reads a file containing function prototypes
|
|
||||||
# (like syscall_darwin.go) and generates system call bodies.
|
|
||||||
# The prototypes are marked by lines beginning with "//sys"
|
|
||||||
# and read like func declarations if //sys is replaced by func, but:
|
|
||||||
# * The parameter lists must give a name for each argument.
|
|
||||||
# This includes return parameters.
|
|
||||||
# * The parameter lists must give a type for each argument:
|
|
||||||
# the (x, y, z int) shorthand is not allowed.
|
|
||||||
# * If the return parameter is an error number, it must be named errno.
|
|
||||||
|
|
||||||
# A line beginning with //sysnb is like //sys, except that the
|
|
||||||
# goroutine will not be suspended during the execution of the system
|
|
||||||
# call. This must only be used for system calls which can never
|
|
||||||
# block, as otherwise the system call could cause all goroutines to
|
|
||||||
# hang.
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
my $cmdline = "mksyscall.pl " . join(' ', @ARGV);
|
|
||||||
my $errors = 0;
|
|
||||||
my $_32bit = "";
|
|
||||||
my $plan9 = 0;
|
|
||||||
my $openbsd = 0;
|
|
||||||
my $netbsd = 0;
|
|
||||||
my $dragonfly = 0;
|
|
||||||
my $arm = 0; # 64-bit value should use (even, odd)-pair
|
|
||||||
my $tags = ""; # build tags
|
|
||||||
|
|
||||||
if($ARGV[0] eq "-b32") {
|
|
||||||
$_32bit = "big-endian";
|
|
||||||
shift;
|
|
||||||
} elsif($ARGV[0] eq "-l32") {
|
|
||||||
$_32bit = "little-endian";
|
|
||||||
shift;
|
|
||||||
}
|
|
||||||
if($ARGV[0] eq "-plan9") {
|
|
||||||
$plan9 = 1;
|
|
||||||
shift;
|
|
||||||
}
|
|
||||||
if($ARGV[0] eq "-openbsd") {
|
|
||||||
$openbsd = 1;
|
|
||||||
shift;
|
|
||||||
}
|
|
||||||
if($ARGV[0] eq "-netbsd") {
|
|
||||||
$netbsd = 1;
|
|
||||||
shift;
|
|
||||||
}
|
|
||||||
if($ARGV[0] eq "-dragonfly") {
|
|
||||||
$dragonfly = 1;
|
|
||||||
shift;
|
|
||||||
}
|
|
||||||
if($ARGV[0] eq "-arm") {
|
|
||||||
$arm = 1;
|
|
||||||
shift;
|
|
||||||
}
|
|
||||||
if($ARGV[0] eq "-tags") {
|
|
||||||
shift;
|
|
||||||
$tags = $ARGV[0];
|
|
||||||
shift;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($ARGV[0] =~ /^-/) {
|
|
||||||
print STDERR "usage: mksyscall.pl [-b32 | -l32] [-tags x,y] [file ...]\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check that we are using the new build system if we should
|
|
||||||
if($ENV{'GOOS'} eq "linux" && $ENV{'GOARCH'} ne "sparc64") {
|
|
||||||
if($ENV{'GOLANG_SYS_BUILD'} ne "docker") {
|
|
||||||
print STDERR "In the new build system, mksyscall should not be called directly.\n";
|
|
||||||
print STDERR "See README.md\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub parseparamlist($) {
|
|
||||||
my ($list) = @_;
|
|
||||||
$list =~ s/^\s*//;
|
|
||||||
$list =~ s/\s*$//;
|
|
||||||
if($list eq "") {
|
|
||||||
return ();
|
|
||||||
}
|
|
||||||
return split(/\s*,\s*/, $list);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub parseparam($) {
|
|
||||||
my ($p) = @_;
|
|
||||||
if($p !~ /^(\S*) (\S*)$/) {
|
|
||||||
print STDERR "$ARGV:$.: malformed parameter: $p\n";
|
|
||||||
$errors = 1;
|
|
||||||
return ("xx", "int");
|
|
||||||
}
|
|
||||||
return ($1, $2);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $text = "";
|
|
||||||
while(<>) {
|
|
||||||
chomp;
|
|
||||||
s/\s+/ /g;
|
|
||||||
s/^\s+//;
|
|
||||||
s/\s+$//;
|
|
||||||
my $nonblock = /^\/\/sysnb /;
|
|
||||||
next if !/^\/\/sys / && !$nonblock;
|
|
||||||
|
|
||||||
# Line must be of the form
|
|
||||||
# func Open(path string, mode int, perm int) (fd int, errno error)
|
|
||||||
# Split into name, in params, out params.
|
|
||||||
if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) {
|
|
||||||
print STDERR "$ARGV:$.: malformed //sys declaration\n";
|
|
||||||
$errors = 1;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my ($func, $in, $out, $sysname) = ($2, $3, $4, $5);
|
|
||||||
|
|
||||||
# Split argument lists on comma.
|
|
||||||
my @in = parseparamlist($in);
|
|
||||||
my @out = parseparamlist($out);
|
|
||||||
|
|
||||||
# Try in vain to keep people from editing this file.
|
|
||||||
# The theory is that they jump into the middle of the file
|
|
||||||
# without reading the header.
|
|
||||||
$text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
|
|
||||||
|
|
||||||
# Go function header.
|
|
||||||
my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
|
|
||||||
$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
|
|
||||||
|
|
||||||
# Check if err return available
|
|
||||||
my $errvar = "";
|
|
||||||
foreach my $p (@out) {
|
|
||||||
my ($name, $type) = parseparam($p);
|
|
||||||
if($type eq "error") {
|
|
||||||
$errvar = $name;
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Prepare arguments to Syscall.
|
|
||||||
my @args = ();
|
|
||||||
my $n = 0;
|
|
||||||
foreach my $p (@in) {
|
|
||||||
my ($name, $type) = parseparam($p);
|
|
||||||
if($type =~ /^\*/) {
|
|
||||||
push @args, "uintptr(unsafe.Pointer($name))";
|
|
||||||
} elsif($type eq "string" && $errvar ne "") {
|
|
||||||
$text .= "\tvar _p$n *byte\n";
|
|
||||||
$text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
|
|
||||||
$text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
|
|
||||||
push @args, "uintptr(unsafe.Pointer(_p$n))";
|
|
||||||
$n++;
|
|
||||||
} elsif($type eq "string") {
|
|
||||||
print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
|
|
||||||
$text .= "\tvar _p$n *byte\n";
|
|
||||||
$text .= "\t_p$n, _ = BytePtrFromString($name)\n";
|
|
||||||
push @args, "uintptr(unsafe.Pointer(_p$n))";
|
|
||||||
$n++;
|
|
||||||
} elsif($type =~ /^\[\](.*)/) {
|
|
||||||
# Convert slice into pointer, length.
|
|
||||||
# Have to be careful not to take address of &a[0] if len == 0:
|
|
||||||
# pass dummy pointer in that case.
|
|
||||||
# Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
|
|
||||||
$text .= "\tvar _p$n unsafe.Pointer\n";
|
|
||||||
$text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}";
|
|
||||||
$text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}";
|
|
||||||
$text .= "\n";
|
|
||||||
push @args, "uintptr(_p$n)", "uintptr(len($name))";
|
|
||||||
$n++;
|
|
||||||
} elsif($type eq "int64" && ($openbsd || $netbsd)) {
|
|
||||||
push @args, "0";
|
|
||||||
if($_32bit eq "big-endian") {
|
|
||||||
push @args, "uintptr($name>>32)", "uintptr($name)";
|
|
||||||
} elsif($_32bit eq "little-endian") {
|
|
||||||
push @args, "uintptr($name)", "uintptr($name>>32)";
|
|
||||||
} else {
|
|
||||||
push @args, "uintptr($name)";
|
|
||||||
}
|
|
||||||
} elsif($type eq "int64" && $dragonfly) {
|
|
||||||
if ($func !~ /^extp(read|write)/i) {
|
|
||||||
push @args, "0";
|
|
||||||
}
|
|
||||||
if($_32bit eq "big-endian") {
|
|
||||||
push @args, "uintptr($name>>32)", "uintptr($name)";
|
|
||||||
} elsif($_32bit eq "little-endian") {
|
|
||||||
push @args, "uintptr($name)", "uintptr($name>>32)";
|
|
||||||
} else {
|
|
||||||
push @args, "uintptr($name)";
|
|
||||||
}
|
|
||||||
} elsif($type eq "int64" && $_32bit ne "") {
|
|
||||||
if(@args % 2 && $arm) {
|
|
||||||
# arm abi specifies 64-bit argument uses
|
|
||||||
# (even, odd) pair
|
|
||||||
push @args, "0"
|
|
||||||
}
|
|
||||||
if($_32bit eq "big-endian") {
|
|
||||||
push @args, "uintptr($name>>32)", "uintptr($name)";
|
|
||||||
} else {
|
|
||||||
push @args, "uintptr($name)", "uintptr($name>>32)";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
push @args, "uintptr($name)";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Determine which form to use; pad args with zeros.
|
|
||||||
my $asm = "Syscall";
|
|
||||||
if ($nonblock) {
|
|
||||||
$asm = "RawSyscall";
|
|
||||||
}
|
|
||||||
if(@args <= 3) {
|
|
||||||
while(@args < 3) {
|
|
||||||
push @args, "0";
|
|
||||||
}
|
|
||||||
} elsif(@args <= 6) {
|
|
||||||
$asm .= "6";
|
|
||||||
while(@args < 6) {
|
|
||||||
push @args, "0";
|
|
||||||
}
|
|
||||||
} elsif(@args <= 9) {
|
|
||||||
$asm .= "9";
|
|
||||||
while(@args < 9) {
|
|
||||||
push @args, "0";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print STDERR "$ARGV:$.: too many arguments to system call\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
# System call number.
|
|
||||||
if($sysname eq "") {
|
|
||||||
$sysname = "SYS_$func";
|
|
||||||
$sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into Foo_Bar
|
|
||||||
$sysname =~ y/a-z/A-Z/;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Actual call.
|
|
||||||
my $args = join(', ', @args);
|
|
||||||
my $call = "$asm($sysname, $args)";
|
|
||||||
|
|
||||||
# Assign return values.
|
|
||||||
my $body = "";
|
|
||||||
my @ret = ("_", "_", "_");
|
|
||||||
my $do_errno = 0;
|
|
||||||
for(my $i=0; $i<@out; $i++) {
|
|
||||||
my $p = $out[$i];
|
|
||||||
my ($name, $type) = parseparam($p);
|
|
||||||
my $reg = "";
|
|
||||||
if($name eq "err" && !$plan9) {
|
|
||||||
$reg = "e1";
|
|
||||||
$ret[2] = $reg;
|
|
||||||
$do_errno = 1;
|
|
||||||
} elsif($name eq "err" && $plan9) {
|
|
||||||
$ret[0] = "r0";
|
|
||||||
$ret[2] = "e1";
|
|
||||||
next;
|
|
||||||
} else {
|
|
||||||
$reg = sprintf("r%d", $i);
|
|
||||||
$ret[$i] = $reg;
|
|
||||||
}
|
|
||||||
if($type eq "bool") {
|
|
||||||
$reg = "$reg != 0";
|
|
||||||
}
|
|
||||||
if($type eq "int64" && $_32bit ne "") {
|
|
||||||
# 64-bit number in r1:r0 or r0:r1.
|
|
||||||
if($i+2 > @out) {
|
|
||||||
print STDERR "$ARGV:$.: not enough registers for int64 return\n";
|
|
||||||
}
|
|
||||||
if($_32bit eq "big-endian") {
|
|
||||||
$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
|
|
||||||
} else {
|
|
||||||
$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
|
|
||||||
}
|
|
||||||
$ret[$i] = sprintf("r%d", $i);
|
|
||||||
$ret[$i+1] = sprintf("r%d", $i+1);
|
|
||||||
}
|
|
||||||
if($reg ne "e1" || $plan9) {
|
|
||||||
$body .= "\t$name = $type($reg)\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
|
|
||||||
$text .= "\t$call\n";
|
|
||||||
} else {
|
|
||||||
$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
|
|
||||||
}
|
|
||||||
$text .= $body;
|
|
||||||
|
|
||||||
if ($plan9 && $ret[2] eq "e1") {
|
|
||||||
$text .= "\tif int32(r0) == -1 {\n";
|
|
||||||
$text .= "\t\terr = e1\n";
|
|
||||||
$text .= "\t}\n";
|
|
||||||
} elsif ($do_errno) {
|
|
||||||
$text .= "\tif e1 != 0 {\n";
|
|
||||||
$text .= "\t\terr = errnoErr(e1)\n";
|
|
||||||
$text .= "\t}\n";
|
|
||||||
}
|
|
||||||
$text .= "\treturn\n";
|
|
||||||
$text .= "}\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
chomp $text;
|
|
||||||
chomp $text;
|
|
||||||
|
|
||||||
if($errors) {
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
// $cmdline
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build $tags
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ syscall.Errno
|
|
||||||
|
|
||||||
$text
|
|
||||||
EOF
|
|
||||||
exit 0;
|
|
289
vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
generated
vendored
289
vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
generated
vendored
@ -1,289 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
# Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
# This program reads a file containing function prototypes
|
|
||||||
# (like syscall_solaris.go) and generates system call bodies.
|
|
||||||
# The prototypes are marked by lines beginning with "//sys"
|
|
||||||
# and read like func declarations if //sys is replaced by func, but:
|
|
||||||
# * The parameter lists must give a name for each argument.
|
|
||||||
# This includes return parameters.
|
|
||||||
# * The parameter lists must give a type for each argument:
|
|
||||||
# the (x, y, z int) shorthand is not allowed.
|
|
||||||
# * If the return parameter is an error number, it must be named err.
|
|
||||||
# * If go func name needs to be different than its libc name,
|
|
||||||
# * or the function is not in libc, name could be specified
|
|
||||||
# * at the end, after "=" sign, like
|
|
||||||
# //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
my $cmdline = "mksyscall_solaris.pl " . join(' ', @ARGV);
|
|
||||||
my $errors = 0;
|
|
||||||
my $_32bit = "";
|
|
||||||
my $tags = ""; # build tags
|
|
||||||
|
|
||||||
binmode STDOUT;
|
|
||||||
|
|
||||||
if($ARGV[0] eq "-b32") {
|
|
||||||
$_32bit = "big-endian";
|
|
||||||
shift;
|
|
||||||
} elsif($ARGV[0] eq "-l32") {
|
|
||||||
$_32bit = "little-endian";
|
|
||||||
shift;
|
|
||||||
}
|
|
||||||
if($ARGV[0] eq "-tags") {
|
|
||||||
shift;
|
|
||||||
$tags = $ARGV[0];
|
|
||||||
shift;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($ARGV[0] =~ /^-/) {
|
|
||||||
print STDERR "usage: mksyscall_solaris.pl [-b32 | -l32] [-tags x,y] [file ...]\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub parseparamlist($) {
|
|
||||||
my ($list) = @_;
|
|
||||||
$list =~ s/^\s*//;
|
|
||||||
$list =~ s/\s*$//;
|
|
||||||
if($list eq "") {
|
|
||||||
return ();
|
|
||||||
}
|
|
||||||
return split(/\s*,\s*/, $list);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub parseparam($) {
|
|
||||||
my ($p) = @_;
|
|
||||||
if($p !~ /^(\S*) (\S*)$/) {
|
|
||||||
print STDERR "$ARGV:$.: malformed parameter: $p\n";
|
|
||||||
$errors = 1;
|
|
||||||
return ("xx", "int");
|
|
||||||
}
|
|
||||||
return ($1, $2);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $package = "";
|
|
||||||
my $text = "";
|
|
||||||
my $dynimports = "";
|
|
||||||
my $linknames = "";
|
|
||||||
my @vars = ();
|
|
||||||
while(<>) {
|
|
||||||
chomp;
|
|
||||||
s/\s+/ /g;
|
|
||||||
s/^\s+//;
|
|
||||||
s/\s+$//;
|
|
||||||
$package = $1 if !$package && /^package (\S+)$/;
|
|
||||||
my $nonblock = /^\/\/sysnb /;
|
|
||||||
next if !/^\/\/sys / && !$nonblock;
|
|
||||||
|
|
||||||
# Line must be of the form
|
|
||||||
# func Open(path string, mode int, perm int) (fd int, err error)
|
|
||||||
# Split into name, in params, out params.
|
|
||||||
if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) {
|
|
||||||
print STDERR "$ARGV:$.: malformed //sys declaration\n";
|
|
||||||
$errors = 1;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, $6);
|
|
||||||
|
|
||||||
# Split argument lists on comma.
|
|
||||||
my @in = parseparamlist($in);
|
|
||||||
my @out = parseparamlist($out);
|
|
||||||
|
|
||||||
# So file name.
|
|
||||||
if($modname eq "") {
|
|
||||||
$modname = "libc";
|
|
||||||
}
|
|
||||||
|
|
||||||
# System call name.
|
|
||||||
if($sysname eq "") {
|
|
||||||
$sysname = "$func";
|
|
||||||
}
|
|
||||||
|
|
||||||
# System call pointer variable name.
|
|
||||||
my $sysvarname = "proc$sysname";
|
|
||||||
|
|
||||||
my $strconvfunc = "BytePtrFromString";
|
|
||||||
my $strconvtype = "*byte";
|
|
||||||
|
|
||||||
$sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
|
|
||||||
|
|
||||||
# Runtime import of function to allow cross-platform builds.
|
|
||||||
$dynimports .= "//go:cgo_import_dynamic libc_${sysname} ${sysname} \"$modname.so\"\n";
|
|
||||||
# Link symbol to proc address variable.
|
|
||||||
$linknames .= "//go:linkname ${sysvarname} libc_${sysname}\n";
|
|
||||||
# Library proc address variable.
|
|
||||||
push @vars, $sysvarname;
|
|
||||||
|
|
||||||
# Go function header.
|
|
||||||
$out = join(', ', @out);
|
|
||||||
if($out ne "") {
|
|
||||||
$out = " ($out)";
|
|
||||||
}
|
|
||||||
if($text ne "") {
|
|
||||||
$text .= "\n"
|
|
||||||
}
|
|
||||||
$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out;
|
|
||||||
|
|
||||||
# Check if err return available
|
|
||||||
my $errvar = "";
|
|
||||||
foreach my $p (@out) {
|
|
||||||
my ($name, $type) = parseparam($p);
|
|
||||||
if($type eq "error") {
|
|
||||||
$errvar = $name;
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Prepare arguments to Syscall.
|
|
||||||
my @args = ();
|
|
||||||
my $n = 0;
|
|
||||||
foreach my $p (@in) {
|
|
||||||
my ($name, $type) = parseparam($p);
|
|
||||||
if($type =~ /^\*/) {
|
|
||||||
push @args, "uintptr(unsafe.Pointer($name))";
|
|
||||||
} elsif($type eq "string" && $errvar ne "") {
|
|
||||||
$text .= "\tvar _p$n $strconvtype\n";
|
|
||||||
$text .= "\t_p$n, $errvar = $strconvfunc($name)\n";
|
|
||||||
$text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
|
|
||||||
push @args, "uintptr(unsafe.Pointer(_p$n))";
|
|
||||||
$n++;
|
|
||||||
} elsif($type eq "string") {
|
|
||||||
print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
|
|
||||||
$text .= "\tvar _p$n $strconvtype\n";
|
|
||||||
$text .= "\t_p$n, _ = $strconvfunc($name)\n";
|
|
||||||
push @args, "uintptr(unsafe.Pointer(_p$n))";
|
|
||||||
$n++;
|
|
||||||
} elsif($type =~ /^\[\](.*)/) {
|
|
||||||
# Convert slice into pointer, length.
|
|
||||||
# Have to be careful not to take address of &a[0] if len == 0:
|
|
||||||
# pass nil in that case.
|
|
||||||
$text .= "\tvar _p$n *$1\n";
|
|
||||||
$text .= "\tif len($name) > 0 {\n\t\t_p$n = \&$name\[0]\n\t}\n";
|
|
||||||
push @args, "uintptr(unsafe.Pointer(_p$n))", "uintptr(len($name))";
|
|
||||||
$n++;
|
|
||||||
} elsif($type eq "int64" && $_32bit ne "") {
|
|
||||||
if($_32bit eq "big-endian") {
|
|
||||||
push @args, "uintptr($name >> 32)", "uintptr($name)";
|
|
||||||
} else {
|
|
||||||
push @args, "uintptr($name)", "uintptr($name >> 32)";
|
|
||||||
}
|
|
||||||
} elsif($type eq "bool") {
|
|
||||||
$text .= "\tvar _p$n uint32\n";
|
|
||||||
$text .= "\tif $name {\n\t\t_p$n = 1\n\t} else {\n\t\t_p$n = 0\n\t}\n";
|
|
||||||
push @args, "uintptr(_p$n)";
|
|
||||||
$n++;
|
|
||||||
} else {
|
|
||||||
push @args, "uintptr($name)";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
my $nargs = @args;
|
|
||||||
|
|
||||||
# Determine which form to use; pad args with zeros.
|
|
||||||
my $asm = "sysvicall6";
|
|
||||||
if ($nonblock) {
|
|
||||||
$asm = "rawSysvicall6";
|
|
||||||
}
|
|
||||||
if(@args <= 6) {
|
|
||||||
while(@args < 6) {
|
|
||||||
push @args, "0";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print STDERR "$ARGV:$.: too many arguments to system call\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Actual call.
|
|
||||||
my $args = join(', ', @args);
|
|
||||||
my $call = "$asm(uintptr(unsafe.Pointer(&$sysvarname)), $nargs, $args)";
|
|
||||||
|
|
||||||
# Assign return values.
|
|
||||||
my $body = "";
|
|
||||||
my $failexpr = "";
|
|
||||||
my @ret = ("_", "_", "_");
|
|
||||||
my @pout= ();
|
|
||||||
my $do_errno = 0;
|
|
||||||
for(my $i=0; $i<@out; $i++) {
|
|
||||||
my $p = $out[$i];
|
|
||||||
my ($name, $type) = parseparam($p);
|
|
||||||
my $reg = "";
|
|
||||||
if($name eq "err") {
|
|
||||||
$reg = "e1";
|
|
||||||
$ret[2] = $reg;
|
|
||||||
$do_errno = 1;
|
|
||||||
} else {
|
|
||||||
$reg = sprintf("r%d", $i);
|
|
||||||
$ret[$i] = $reg;
|
|
||||||
}
|
|
||||||
if($type eq "bool") {
|
|
||||||
$reg = "$reg != 0";
|
|
||||||
}
|
|
||||||
if($type eq "int64" && $_32bit ne "") {
|
|
||||||
# 64-bit number in r1:r0 or r0:r1.
|
|
||||||
if($i+2 > @out) {
|
|
||||||
print STDERR "$ARGV:$.: not enough registers for int64 return\n";
|
|
||||||
}
|
|
||||||
if($_32bit eq "big-endian") {
|
|
||||||
$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
|
|
||||||
} else {
|
|
||||||
$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
|
|
||||||
}
|
|
||||||
$ret[$i] = sprintf("r%d", $i);
|
|
||||||
$ret[$i+1] = sprintf("r%d", $i+1);
|
|
||||||
}
|
|
||||||
if($reg ne "e1") {
|
|
||||||
$body .= "\t$name = $type($reg)\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
|
|
||||||
$text .= "\t$call\n";
|
|
||||||
} else {
|
|
||||||
$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
|
|
||||||
}
|
|
||||||
$text .= $body;
|
|
||||||
|
|
||||||
if ($do_errno) {
|
|
||||||
$text .= "\tif e1 != 0 {\n";
|
|
||||||
$text .= "\t\terr = e1\n";
|
|
||||||
$text .= "\t}\n";
|
|
||||||
}
|
|
||||||
$text .= "\treturn\n";
|
|
||||||
$text .= "}\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if($errors) {
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
// $cmdline
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build $tags
|
|
||||||
|
|
||||||
package $package
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
EOF
|
|
||||||
|
|
||||||
print "import \"golang.org/x/sys/unix\"\n" if $package ne "unix";
|
|
||||||
|
|
||||||
my $vardecls = "\t" . join(",\n\t", @vars);
|
|
||||||
$vardecls .= " syscallFunc";
|
|
||||||
|
|
||||||
chomp($_=<<EOF);
|
|
||||||
|
|
||||||
$dynimports
|
|
||||||
$linknames
|
|
||||||
var (
|
|
||||||
$vardecls
|
|
||||||
)
|
|
||||||
|
|
||||||
$text
|
|
||||||
EOF
|
|
||||||
print $_;
|
|
||||||
exit 0;
|
|
264
vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
generated
vendored
264
vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
generated
vendored
@ -1,264 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
|
|
||||||
# Copyright 2011 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
#
|
|
||||||
# Parse the header files for OpenBSD and generate a Go usable sysctl MIB.
|
|
||||||
#
|
|
||||||
# Build a MIB with each entry being an array containing the level, type and
|
|
||||||
# a hash that will contain additional entries if the current entry is a node.
|
|
||||||
# We then walk this MIB and create a flattened sysctl name to OID hash.
|
|
||||||
#
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
|
||||||
print STDERR "GOARCH or GOOS not defined in environment\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $debug = 0;
|
|
||||||
my %ctls = ();
|
|
||||||
|
|
||||||
my @headers = qw (
|
|
||||||
sys/sysctl.h
|
|
||||||
sys/socket.h
|
|
||||||
sys/tty.h
|
|
||||||
sys/malloc.h
|
|
||||||
sys/mount.h
|
|
||||||
sys/namei.h
|
|
||||||
sys/sem.h
|
|
||||||
sys/shm.h
|
|
||||||
sys/vmmeter.h
|
|
||||||
uvm/uvm_param.h
|
|
||||||
uvm/uvm_swap_encrypt.h
|
|
||||||
ddb/db_var.h
|
|
||||||
net/if.h
|
|
||||||
net/if_pfsync.h
|
|
||||||
net/pipex.h
|
|
||||||
netinet/in.h
|
|
||||||
netinet/icmp_var.h
|
|
||||||
netinet/igmp_var.h
|
|
||||||
netinet/ip_ah.h
|
|
||||||
netinet/ip_carp.h
|
|
||||||
netinet/ip_divert.h
|
|
||||||
netinet/ip_esp.h
|
|
||||||
netinet/ip_ether.h
|
|
||||||
netinet/ip_gre.h
|
|
||||||
netinet/ip_ipcomp.h
|
|
||||||
netinet/ip_ipip.h
|
|
||||||
netinet/pim_var.h
|
|
||||||
netinet/tcp_var.h
|
|
||||||
netinet/udp_var.h
|
|
||||||
netinet6/in6.h
|
|
||||||
netinet6/ip6_divert.h
|
|
||||||
netinet6/pim6_var.h
|
|
||||||
netinet/icmp6.h
|
|
||||||
netmpls/mpls.h
|
|
||||||
);
|
|
||||||
|
|
||||||
my @ctls = qw (
|
|
||||||
kern
|
|
||||||
vm
|
|
||||||
fs
|
|
||||||
net
|
|
||||||
#debug # Special handling required
|
|
||||||
hw
|
|
||||||
#machdep # Arch specific
|
|
||||||
user
|
|
||||||
ddb
|
|
||||||
#vfs # Special handling required
|
|
||||||
fs.posix
|
|
||||||
kern.forkstat
|
|
||||||
kern.intrcnt
|
|
||||||
kern.malloc
|
|
||||||
kern.nchstats
|
|
||||||
kern.seminfo
|
|
||||||
kern.shminfo
|
|
||||||
kern.timecounter
|
|
||||||
kern.tty
|
|
||||||
kern.watchdog
|
|
||||||
net.bpf
|
|
||||||
net.ifq
|
|
||||||
net.inet
|
|
||||||
net.inet.ah
|
|
||||||
net.inet.carp
|
|
||||||
net.inet.divert
|
|
||||||
net.inet.esp
|
|
||||||
net.inet.etherip
|
|
||||||
net.inet.gre
|
|
||||||
net.inet.icmp
|
|
||||||
net.inet.igmp
|
|
||||||
net.inet.ip
|
|
||||||
net.inet.ip.ifq
|
|
||||||
net.inet.ipcomp
|
|
||||||
net.inet.ipip
|
|
||||||
net.inet.mobileip
|
|
||||||
net.inet.pfsync
|
|
||||||
net.inet.pim
|
|
||||||
net.inet.tcp
|
|
||||||
net.inet.udp
|
|
||||||
net.inet6
|
|
||||||
net.inet6.divert
|
|
||||||
net.inet6.ip6
|
|
||||||
net.inet6.icmp6
|
|
||||||
net.inet6.pim6
|
|
||||||
net.inet6.tcp6
|
|
||||||
net.inet6.udp6
|
|
||||||
net.mpls
|
|
||||||
net.mpls.ifq
|
|
||||||
net.key
|
|
||||||
net.pflow
|
|
||||||
net.pfsync
|
|
||||||
net.pipex
|
|
||||||
net.rt
|
|
||||||
vm.swapencrypt
|
|
||||||
#vfsgenctl # Special handling required
|
|
||||||
);
|
|
||||||
|
|
||||||
# Node name "fixups"
|
|
||||||
my %ctl_map = (
|
|
||||||
"ipproto" => "net.inet",
|
|
||||||
"net.inet.ipproto" => "net.inet",
|
|
||||||
"net.inet6.ipv6proto" => "net.inet6",
|
|
||||||
"net.inet6.ipv6" => "net.inet6.ip6",
|
|
||||||
"net.inet.icmpv6" => "net.inet6.icmp6",
|
|
||||||
"net.inet6.divert6" => "net.inet6.divert",
|
|
||||||
"net.inet6.tcp6" => "net.inet.tcp",
|
|
||||||
"net.inet6.udp6" => "net.inet.udp",
|
|
||||||
"mpls" => "net.mpls",
|
|
||||||
"swpenc" => "vm.swapencrypt"
|
|
||||||
);
|
|
||||||
|
|
||||||
# Node mappings
|
|
||||||
my %node_map = (
|
|
||||||
"net.inet.ip.ifq" => "net.ifq",
|
|
||||||
"net.inet.pfsync" => "net.pfsync",
|
|
||||||
"net.mpls.ifq" => "net.ifq"
|
|
||||||
);
|
|
||||||
|
|
||||||
my $ctlname;
|
|
||||||
my %mib = ();
|
|
||||||
my %sysctl = ();
|
|
||||||
my $node;
|
|
||||||
|
|
||||||
sub debug() {
|
|
||||||
print STDERR "$_[0]\n" if $debug;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Walk the MIB and build a sysctl name to OID mapping.
|
|
||||||
sub build_sysctl() {
|
|
||||||
my ($node, $name, $oid) = @_;
|
|
||||||
my %node = %{$node};
|
|
||||||
my @oid = @{$oid};
|
|
||||||
|
|
||||||
foreach my $key (sort keys %node) {
|
|
||||||
my @node = @{$node{$key}};
|
|
||||||
my $nodename = $name.($name ne '' ? '.' : '').$key;
|
|
||||||
my @nodeoid = (@oid, $node[0]);
|
|
||||||
if ($node[1] eq 'CTLTYPE_NODE') {
|
|
||||||
if (exists $node_map{$nodename}) {
|
|
||||||
$node = \%mib;
|
|
||||||
$ctlname = $node_map{$nodename};
|
|
||||||
foreach my $part (split /\./, $ctlname) {
|
|
||||||
$node = \%{@{$$node{$part}}[2]};
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$node = $node[2];
|
|
||||||
}
|
|
||||||
&build_sysctl($node, $nodename, \@nodeoid);
|
|
||||||
} elsif ($node[1] ne '') {
|
|
||||||
$sysctl{$nodename} = \@nodeoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $ctl (@ctls) {
|
|
||||||
$ctls{$ctl} = $ctl;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Build MIB
|
|
||||||
foreach my $header (@headers) {
|
|
||||||
&debug("Processing $header...");
|
|
||||||
open HEADER, "/usr/include/$header" ||
|
|
||||||
print STDERR "Failed to open $header\n";
|
|
||||||
while (<HEADER>) {
|
|
||||||
if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ ||
|
|
||||||
$_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ ||
|
|
||||||
$_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) {
|
|
||||||
if ($1 eq 'CTL_NAMES') {
|
|
||||||
# Top level.
|
|
||||||
$node = \%mib;
|
|
||||||
} else {
|
|
||||||
# Node.
|
|
||||||
my $nodename = lc($2);
|
|
||||||
if ($header =~ /^netinet\//) {
|
|
||||||
$ctlname = "net.inet.$nodename";
|
|
||||||
} elsif ($header =~ /^netinet6\//) {
|
|
||||||
$ctlname = "net.inet6.$nodename";
|
|
||||||
} elsif ($header =~ /^net\//) {
|
|
||||||
$ctlname = "net.$nodename";
|
|
||||||
} else {
|
|
||||||
$ctlname = "$nodename";
|
|
||||||
$ctlname =~ s/^(fs|net|kern)_/$1\./;
|
|
||||||
}
|
|
||||||
if (exists $ctl_map{$ctlname}) {
|
|
||||||
$ctlname = $ctl_map{$ctlname};
|
|
||||||
}
|
|
||||||
if (not exists $ctls{$ctlname}) {
|
|
||||||
&debug("Ignoring $ctlname...");
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Walk down from the top of the MIB.
|
|
||||||
$node = \%mib;
|
|
||||||
foreach my $part (split /\./, $ctlname) {
|
|
||||||
if (not exists $$node{$part}) {
|
|
||||||
&debug("Missing node $part");
|
|
||||||
$$node{$part} = [ 0, '', {} ];
|
|
||||||
}
|
|
||||||
$node = \%{@{$$node{$part}}[2]};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Populate current node with entries.
|
|
||||||
my $i = -1;
|
|
||||||
while (defined($_) && $_ !~ /^}/) {
|
|
||||||
$_ = <HEADER>;
|
|
||||||
$i++ if $_ =~ /{.*}/;
|
|
||||||
next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/;
|
|
||||||
$$node{$1} = [ $i, $2, {} ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close HEADER;
|
|
||||||
}
|
|
||||||
|
|
||||||
&build_sysctl(\%mib, "", []);
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
// mksysctl_openbsd.pl
|
|
||||||
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
|
|
||||||
|
|
||||||
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
|
||||||
|
|
||||||
package unix;
|
|
||||||
|
|
||||||
type mibentry struct {
|
|
||||||
ctlname string
|
|
||||||
ctloid []_C_int
|
|
||||||
}
|
|
||||||
|
|
||||||
var sysctlMib = []mibentry {
|
|
||||||
EOF
|
|
||||||
|
|
||||||
foreach my $name (sort keys %sysctl) {
|
|
||||||
my @oid = @{$sysctl{$name}};
|
|
||||||
print "\t{ \"$name\", []_C_int{ ", join(', ', @oid), " } }, \n";
|
|
||||||
}
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
}
|
|
||||||
EOF
|
|
39
vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
generated
vendored
39
vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
generated
vendored
@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
# Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
#
|
|
||||||
# Generate system call table for Darwin from sys/syscall.h
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
|
||||||
print STDERR "GOARCH or GOOS not defined in environment\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $command = "mksysnum_darwin.pl " . join(' ', @ARGV);
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
// $command
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
EOF
|
|
||||||
|
|
||||||
while(<>){
|
|
||||||
if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){
|
|
||||||
my $name = $1;
|
|
||||||
my $num = $2;
|
|
||||||
$name =~ y/a-z/A-Z/;
|
|
||||||
print " SYS_$name = $num;"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
)
|
|
||||||
EOF
|
|
50
vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
generated
vendored
50
vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
generated
vendored
@ -1,50 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
# Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
#
|
|
||||||
# Generate system call table for DragonFly from master list
|
|
||||||
# (for example, /usr/src/sys/kern/syscalls.master).
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
|
||||||
print STDERR "GOARCH or GOOS not defined in environment\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV);
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
// $command
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
EOF
|
|
||||||
|
|
||||||
while(<>){
|
|
||||||
if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){
|
|
||||||
my $num = $1;
|
|
||||||
my $proto = $2;
|
|
||||||
my $name = "SYS_$3";
|
|
||||||
$name =~ y/a-z/A-Z/;
|
|
||||||
|
|
||||||
# There are multiple entries for enosys and nosys, so comment them out.
|
|
||||||
if($name =~ /^SYS_E?NOSYS$/){
|
|
||||||
$name = "// $name";
|
|
||||||
}
|
|
||||||
if($name eq 'SYS_SYS_EXIT'){
|
|
||||||
$name = 'SYS_EXIT';
|
|
||||||
}
|
|
||||||
|
|
||||||
print " $name = $num; // $proto\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
)
|
|
||||||
EOF
|
|
50
vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
generated
vendored
50
vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
generated
vendored
@ -1,50 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
# Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
#
|
|
||||||
# Generate system call table for FreeBSD from master list
|
|
||||||
# (for example, /usr/src/sys/kern/syscalls.master).
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
|
||||||
print STDERR "GOARCH or GOOS not defined in environment\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $command = "mksysnum_freebsd.pl " . join(' ', @ARGV);
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
// $command
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
EOF
|
|
||||||
|
|
||||||
while(<>){
|
|
||||||
if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
|
|
||||||
my $num = $1;
|
|
||||||
my $proto = $2;
|
|
||||||
my $name = "SYS_$3";
|
|
||||||
$name =~ y/a-z/A-Z/;
|
|
||||||
|
|
||||||
# There are multiple entries for enosys and nosys, so comment them out.
|
|
||||||
if($name =~ /^SYS_E?NOSYS$/){
|
|
||||||
$name = "// $name";
|
|
||||||
}
|
|
||||||
if($name eq 'SYS_SYS_EXIT'){
|
|
||||||
$name = 'SYS_EXIT';
|
|
||||||
}
|
|
||||||
|
|
||||||
print " $name = $num; // $proto\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
)
|
|
||||||
EOF
|
|
58
vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
generated
vendored
58
vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
generated
vendored
@ -1,58 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
# Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
#
|
|
||||||
# Generate system call table for OpenBSD from master list
|
|
||||||
# (for example, /usr/src/sys/kern/syscalls.master).
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
|
||||||
print STDERR "GOARCH or GOOS not defined in environment\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV);
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
// $command
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
EOF
|
|
||||||
|
|
||||||
my $line = '';
|
|
||||||
while(<>){
|
|
||||||
if($line =~ /^(.*)\\$/) {
|
|
||||||
# Handle continuation
|
|
||||||
$line = $1;
|
|
||||||
$_ =~ s/^\s+//;
|
|
||||||
$line .= $_;
|
|
||||||
} else {
|
|
||||||
# New line
|
|
||||||
$line = $_;
|
|
||||||
}
|
|
||||||
next if $line =~ /\\$/;
|
|
||||||
if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
|
|
||||||
my $num = $1;
|
|
||||||
my $proto = $6;
|
|
||||||
my $compat = $8;
|
|
||||||
my $name = "$7_$9";
|
|
||||||
|
|
||||||
$name = "$7_$11" if $11 ne '';
|
|
||||||
$name =~ y/a-z/A-Z/;
|
|
||||||
|
|
||||||
if($compat eq '' || $compat eq '30' || $compat eq '50') {
|
|
||||||
print " $name = $num; // $proto\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
)
|
|
||||||
EOF
|
|
50
vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
generated
vendored
50
vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
generated
vendored
@ -1,50 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
# Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
#
|
|
||||||
# Generate system call table for OpenBSD from master list
|
|
||||||
# (for example, /usr/src/sys/kern/syscalls.master).
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
|
||||||
print STDERR "GOARCH or GOOS not defined in environment\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $command = "mksysnum_openbsd.pl " . join(' ', @ARGV);
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
// $command
|
|
||||||
// Code generated by the command above; see README.md. DO NOT EDIT.
|
|
||||||
|
|
||||||
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
EOF
|
|
||||||
|
|
||||||
while(<>){
|
|
||||||
if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){
|
|
||||||
my $num = $1;
|
|
||||||
my $proto = $3;
|
|
||||||
my $name = $4;
|
|
||||||
$name =~ y/a-z/A-Z/;
|
|
||||||
|
|
||||||
# There are multiple entries for enosys and nosys, so comment them out.
|
|
||||||
if($name =~ /^SYS_E?NOSYS$/){
|
|
||||||
$name = "// $name";
|
|
||||||
}
|
|
||||||
if($name eq 'SYS_SYS_EXIT'){
|
|
||||||
$name = 'SYS_EXIT';
|
|
||||||
}
|
|
||||||
|
|
||||||
print " $name = $num; // $proto\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print <<EOF;
|
|
||||||
)
|
|
||||||
EOF
|
|
38
vendor/golang.org/x/sys/unix/openbsd_pledge.go
generated
vendored
38
vendor/golang.org/x/sys/unix/openbsd_pledge.go
generated
vendored
@ -1,38 +0,0 @@
|
|||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build openbsd
|
|
||||||
// +build 386 amd64 arm
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
SYS_PLEDGE = 108
|
|
||||||
)
|
|
||||||
|
|
||||||
// Pledge implements the pledge syscall. For more information see pledge(2).
|
|
||||||
func Pledge(promises string, paths []string) error {
|
|
||||||
promisesPtr, err := syscall.BytePtrFromString(promises)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil)
|
|
||||||
if paths != nil {
|
|
||||||
var pathsPtr []*byte
|
|
||||||
if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
pathsUnsafe = unsafe.Pointer(&pathsPtr[0])
|
|
||||||
}
|
|
||||||
_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0)
|
|
||||||
if e != 0 {
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
30
vendor/golang.org/x/sys/unix/race.go
generated
vendored
30
vendor/golang.org/x/sys/unix/race.go
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
// Copyright 2012 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin,race linux,race freebsd,race
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import (
|
|
||||||
"runtime"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const raceenabled = true
|
|
||||||
|
|
||||||
func raceAcquire(addr unsafe.Pointer) {
|
|
||||||
runtime.RaceAcquire(addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func raceReleaseMerge(addr unsafe.Pointer) {
|
|
||||||
runtime.RaceReleaseMerge(addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func raceReadRange(addr unsafe.Pointer, len int) {
|
|
||||||
runtime.RaceReadRange(addr, len)
|
|
||||||
}
|
|
||||||
|
|
||||||
func raceWriteRange(addr unsafe.Pointer, len int) {
|
|
||||||
runtime.RaceWriteRange(addr, len)
|
|
||||||
}
|
|
25
vendor/golang.org/x/sys/unix/race0.go
generated
vendored
25
vendor/golang.org/x/sys/unix/race0.go
generated
vendored
@ -1,25 +0,0 @@
|
|||||||
// Copyright 2012 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import (
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const raceenabled = false
|
|
||||||
|
|
||||||
func raceAcquire(addr unsafe.Pointer) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func raceReleaseMerge(addr unsafe.Pointer) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func raceReadRange(addr unsafe.Pointer, len int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func raceWriteRange(addr unsafe.Pointer, len int) {
|
|
||||||
}
|
|
36
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
36
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
@ -1,36 +0,0 @@
|
|||||||
// Copyright 2011 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Socket control messages
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "unsafe"
|
|
||||||
|
|
||||||
// UnixCredentials encodes credentials into a socket control message
|
|
||||||
// for sending to another process. This can be used for
|
|
||||||
// authentication.
|
|
||||||
func UnixCredentials(ucred *Ucred) []byte {
|
|
||||||
b := make([]byte, CmsgSpace(SizeofUcred))
|
|
||||||
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
|
||||||
h.Level = SOL_SOCKET
|
|
||||||
h.Type = SCM_CREDENTIALS
|
|
||||||
h.SetLen(CmsgLen(SizeofUcred))
|
|
||||||
*((*Ucred)(cmsgData(h))) = *ucred
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseUnixCredentials decodes a socket control message that contains
|
|
||||||
// credentials in a Ucred structure. To receive such a message, the
|
|
||||||
// SO_PASSCRED option must be enabled on the socket.
|
|
||||||
func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) {
|
|
||||||
if m.Header.Level != SOL_SOCKET {
|
|
||||||
return nil, EINVAL
|
|
||||||
}
|
|
||||||
if m.Header.Type != SCM_CREDENTIALS {
|
|
||||||
return nil, EINVAL
|
|
||||||
}
|
|
||||||
ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
|
|
||||||
return &ucred, nil
|
|
||||||
}
|
|
104
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
104
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
@ -1,104 +0,0 @@
|
|||||||
// Copyright 2011 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
||||||
|
|
||||||
// Socket control messages
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "unsafe"
|
|
||||||
|
|
||||||
// Round the length of a raw sockaddr up to align it properly.
|
|
||||||
func cmsgAlignOf(salen int) int {
|
|
||||||
salign := sizeofPtr
|
|
||||||
// NOTE: It seems like 64-bit Darwin, DragonFly BSD and
|
|
||||||
// Solaris kernels still require 32-bit aligned access to
|
|
||||||
// network subsystem.
|
|
||||||
if darwin64Bit || dragonfly64Bit || solaris64Bit {
|
|
||||||
salign = 4
|
|
||||||
}
|
|
||||||
return (salen + salign - 1) & ^(salign - 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CmsgLen returns the value to store in the Len field of the Cmsghdr
|
|
||||||
// structure, taking into account any necessary alignment.
|
|
||||||
func CmsgLen(datalen int) int {
|
|
||||||
return cmsgAlignOf(SizeofCmsghdr) + datalen
|
|
||||||
}
|
|
||||||
|
|
||||||
// CmsgSpace returns the number of bytes an ancillary element with
|
|
||||||
// payload of the passed data length occupies.
|
|
||||||
func CmsgSpace(datalen int) int {
|
|
||||||
return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
|
|
||||||
}
|
|
||||||
|
|
||||||
func cmsgData(h *Cmsghdr) unsafe.Pointer {
|
|
||||||
return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// SocketControlMessage represents a socket control message.
|
|
||||||
type SocketControlMessage struct {
|
|
||||||
Header Cmsghdr
|
|
||||||
Data []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseSocketControlMessage parses b as an array of socket control
|
|
||||||
// messages.
|
|
||||||
func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
|
|
||||||
var msgs []SocketControlMessage
|
|
||||||
i := 0
|
|
||||||
for i+CmsgLen(0) <= len(b) {
|
|
||||||
h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
m := SocketControlMessage{Header: *h, Data: dbuf}
|
|
||||||
msgs = append(msgs, m)
|
|
||||||
i += cmsgAlignOf(int(h.Len))
|
|
||||||
}
|
|
||||||
return msgs, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
|
|
||||||
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
|
||||||
if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) {
|
|
||||||
return nil, nil, EINVAL
|
|
||||||
}
|
|
||||||
return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnixRights encodes a set of open file descriptors into a socket
|
|
||||||
// control message for sending to another process.
|
|
||||||
func UnixRights(fds ...int) []byte {
|
|
||||||
datalen := len(fds) * 4
|
|
||||||
b := make([]byte, CmsgSpace(datalen))
|
|
||||||
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
|
||||||
h.Level = SOL_SOCKET
|
|
||||||
h.Type = SCM_RIGHTS
|
|
||||||
h.SetLen(CmsgLen(datalen))
|
|
||||||
data := cmsgData(h)
|
|
||||||
for _, fd := range fds {
|
|
||||||
*(*int32)(data) = int32(fd)
|
|
||||||
data = unsafe.Pointer(uintptr(data) + 4)
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseUnixRights decodes a socket control message that contains an
|
|
||||||
// integer array of open file descriptors from another process.
|
|
||||||
func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
|
|
||||||
if m.Header.Level != SOL_SOCKET {
|
|
||||||
return nil, EINVAL
|
|
||||||
}
|
|
||||||
if m.Header.Type != SCM_RIGHTS {
|
|
||||||
return nil, EINVAL
|
|
||||||
}
|
|
||||||
fds := make([]int, len(m.Data)>>2)
|
|
||||||
for i, j := 0, 0; i < len(m.Data); i += 4 {
|
|
||||||
fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
|
|
||||||
j++
|
|
||||||
}
|
|
||||||
return fds, nil
|
|
||||||
}
|
|
26
vendor/golang.org/x/sys/unix/str.go
generated
vendored
26
vendor/golang.org/x/sys/unix/str.go
generated
vendored
@ -1,26 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
|
|
||||||
if val < 0 {
|
|
||||||
return "-" + uitoa(uint(-val))
|
|
||||||
}
|
|
||||||
return uitoa(uint(val))
|
|
||||||
}
|
|
||||||
|
|
||||||
func uitoa(val uint) string {
|
|
||||||
var buf [32]byte // big enough for int64
|
|
||||||
i := len(buf) - 1
|
|
||||||
for val >= 10 {
|
|
||||||
buf[i] = byte(val%10 + '0')
|
|
||||||
i--
|
|
||||||
val /= 10
|
|
||||||
}
|
|
||||||
buf[i] = byte(val + '0')
|
|
||||||
return string(buf[i:])
|
|
||||||
}
|
|
69
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
69
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
@ -1,69 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
||||||
|
|
||||||
// Package unix contains an interface to the low-level operating system
|
|
||||||
// primitives. OS details vary depending on the underlying system, and
|
|
||||||
// by default, godoc will display OS-specific documentation for the current
|
|
||||||
// system. If you want godoc to display OS documentation for another
|
|
||||||
// system, set $GOOS and $GOARCH to the desired system. For example, if
|
|
||||||
// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
|
|
||||||
// to freebsd and $GOARCH to arm.
|
|
||||||
// The primary use of this package is inside other packages that provide a more
|
|
||||||
// portable interface to the system, such as "os", "time" and "net". Use
|
|
||||||
// those packages rather than this one if you can.
|
|
||||||
// For details of the functions and data types in this package consult
|
|
||||||
// the manuals for the appropriate operating system.
|
|
||||||
// These calls return err == nil to indicate success; otherwise
|
|
||||||
// err represents an operating system error describing the failure and
|
|
||||||
// holds a value of type syscall.Errno.
|
|
||||||
package unix // import "golang.org/x/sys/unix"
|
|
||||||
|
|
||||||
// ByteSliceFromString returns a NUL-terminated slice of bytes
|
|
||||||
// containing the text of s. If s contains a NUL byte at any
|
|
||||||
// location, it returns (nil, EINVAL).
|
|
||||||
func ByteSliceFromString(s string) ([]byte, error) {
|
|
||||||
for i := 0; i < len(s); i++ {
|
|
||||||
if s[i] == 0 {
|
|
||||||
return nil, EINVAL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a := make([]byte, len(s)+1)
|
|
||||||
copy(a, s)
|
|
||||||
return a, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BytePtrFromString returns a pointer to a NUL-terminated array of
|
|
||||||
// bytes containing the text of s. If s contains a NUL byte at any
|
|
||||||
// location, it returns (nil, EINVAL).
|
|
||||||
func BytePtrFromString(s string) (*byte, error) {
|
|
||||||
a, err := ByteSliceFromString(s)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &a[0], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Single-word zero for use when we need a valid pointer to 0 bytes.
|
|
||||||
// See mkunix.pl.
|
|
||||||
var _zero uintptr
|
|
||||||
|
|
||||||
func (ts *Timespec) Unix() (sec int64, nsec int64) {
|
|
||||||
return int64(ts.Sec), int64(ts.Nsec)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tv *Timeval) Unix() (sec int64, nsec int64) {
|
|
||||||
return int64(tv.Sec), int64(tv.Usec) * 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ts *Timespec) Nano() int64 {
|
|
||||||
return int64(ts.Sec)*1e9 + int64(ts.Nsec)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tv *Timeval) Nano() int64 {
|
|
||||||
return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
|
|
||||||
}
|
|
||||||
|
|
||||||
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user